Problem with System.Net.Http after upgrade to 6.3.7 and using framework 4.7.2

Hi!
After upgrading to 6.3.7 we cannot run the site anymore without manipulating web.config and the problem is System.Net.Http.

Using this:

<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.0.0.0" />

Works just fine, but changing to this, which we git when we upgraded:
<dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" /> </dependentAssembly>

Gives a runtime error.

[BadImageFormatException: Det går inte att läsa in filen eller sammansättningen System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a eller ett av dess beroenden. Referenssammansättningar ska inte läsas in för körning. De kan endast läsas in i inläsningskontexten Reflection-only. (Undantag från HRESULT: 0x80131058)]

It guess it is ok to change but when we build the project unsing TeamCity I get this:

The type 'HttpResponseMessage' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

I have tried to Update-Package -ReInstall but that did not work, I still need to refer to 4.0.0.0 to get the site to startup.

I’m using VS2019.

Any ideas?

Thanks!

/Kristoffer

Litium version: 6.3.7

After reinstalling I get this:

<dependentAssembly>
    <assemblyIdentity name="Litium.Studio.UI" publicKeyToken="a4c57654640950e2" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-6.3.4.0" newVersion="6.3.4.0"/>
  </dependentAssembly>

The package is 6.3.7 and I have tried to run Add-AllBindingRedirect without any change, it still wants 6.3.4 instead of 6.3.7.

Maybe that can be a clue?

Change the .csproj package version number and try.

I cannot find any traces 6.3.4 in the .csproj file and System.Net.Http looks like this:

<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
  <Private>True</Private>
  <Private>True</Private>
</Reference>

So it is expecting package version 4.1.1.3 here.
Erase the reference from here and remove the reference also and install the one needed for the solution to run.
And look again what reference version exists after that in same file.

I have added the Nuget package to all related project but no matter how I do the reference is always pointing to this:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\System.Net.Http.dll

And that dll is different than …\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll

I don’t get why and I can’t uninstall the System.Net.Http package because Litium is depending on it.

/Kristoffer

Maybe you need to downgrade .net framework to 4.6.1 in order to run Litium V6.

It has worked just fine with 4.7.2 before upgrading to 6.3.7. Could you try 6.3.7 with 4.7.2?

And we can get it to work with System.Net.Http 2.0

if we are using 4.6.2

1 Like

I just installed a clean 6.3.7 Accelerator on my computer and changed the proj to use 4.7.2 and got the same problem.

Somehow Visual Studio (or the nuget package ssytem) is adding the System.Runtime.InteropServices.RuntimeInformation assembly into the project-references, please remove that and remove the actual System.Runtime.InteropServices.RuntimeInformation.dll from the bin-folder. Try to rebuild the application.

Ensure that you have correct package versions in all projects, this pointing to that some project have a reference to the old version, can be a reference that is created without adding the nuget package.

I’ve tried with no success. Have you done a Accelerator 6.3.7 and .net 4.7.2?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.