Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

Error when loading assembly: Could not load type 'System.Net.Http.HttpContent' from assembly

(1) ShareShare
ReportReport
Posted on by 31
I'm trying to access SharePoint using a simple HttpClient from using System.Net.Http; 
The project builds but the assembly doesn't load on on Plugin Registration Tool. And I see this error:
Unhandled Exception: System.TypeLoadException: Could not load type 'System.Net.Http.HttpContent' from assembly 'CrmVSSolution.Workflows, Version=1.3.0.0, Culture=neutral, PublicKeyToken=dc437796e33d376f' because the method 'get_Headers' has no implementation (no RVA).
   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at Microsoft.Crm.Tools.Libraries.CrmAssemblyReader.RetrievePluginsFromAssembly(String path)
   at Microsoft.Crm.Tools.Libraries.CrmAssemblyReader.RetrievePluginsFromAssembly(String path)
   at Microsoft.Crm.Tools.Libraries.RegistrationHelper.RetrievePluginsFromAssembly(String pathToAssembly, String appPath)
   at Microsoft.Crm.Tools.AssemblyRegistration.PluginRegistrationViewModel.BtnLoadAssemblyClicked()
My project file includes these lines.
    <Reference Include="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Net.Http.dll</HintPath>
    </Reference>
  • Verified answer
    Marcos Profile Picture
    Marcos 31 on at
    Error when loading assembly: Could not load type 'System.Net.Http.HttpContent' from assembly
    Thanks, Sachin, this kind of works. After many tries I found out that I need to set the Nuget package version to 4.0. 
    Probably not the most advised solution, since the package is tagged as vulnerable, but it works.

    If anyone has another suggestion, I'd happily hear it.
  • Verified answer
    Sachin Jadhav Profile Picture
    Sachin Jadhav 131 on at
    Error when loading assembly: Could not load type 'System.Net.Http.HttpContent' from assembly
    Are you adding the direct reference to the assembly "System.Net.Http"?
     
    May be you can give this a try
     
    1. From your project references list remove the reference to "System.net.Http" by right clicking and using Remove option
     
    2. Install the nuget package named "system.net.http"
     
    Here is the package you are installing: https://www.nuget.org/Packages/system.net.http
     
    3. Build your project and then try to register
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans