Packages.config and binding redirects - visual-studio

We're having some build issues due to package issues, but one of our devs got a green build by downgrading a package in the project's packages.config:
<package id="Microsoft.Data.Edm" version="5.6.2" targetFramework="net451" />
This was also added to the project's config file:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
</dependentAssembly>
If we have amended the version in the packages.config to 5.6.2, but still point to 5.6.4 in our binding redirect, what version of the Microsoft.Data.Edm assembly is the project going to use?

Related

Could not load type 'Ninject.Web.WebApi.IWebApiRequestScopeProvider' from assembly 'Ninject.Web.WebApi'

I've recently upgraded my solution to .net Framework 4.8 and updated a load of nuget packages and now I'm having problems getting my API project to launch.
I felt this smelled of bad binding redirect, but I've looked at this and they are as follows...
<dependentAssembly>
<assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Ninject.Web.Common" publicKeyToken="c7192dc5380945e7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.2.0" newVersion="3.3.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Ninject.Web.Common.OwinHost" publicKeyToken="c7192dc5380945e7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.1.0" newVersion="3.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Ninject.Web.WebApi" publicKeyToken="c7192dc5380945e7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.1.0" newVersion="3.3.1.0" />
</dependentAssembly>
And here's the packages.config...
<package id="Ninject" version="3.3.4" targetFramework="net48" />
<package id="Ninject.Extensions.NamedScope" version="3.3.0" targetFramework="net48" />
<package id="Ninject.Web.Common" version="3.3.2" targetFramework="net48" />
<package id="Ninject.Web.Common.OwinHost" version="3.3.1" targetFramework="net48" />
<package id="Ninject.Web.Common.WebHost" version="3.3.2" targetFramework="net48" />
<package id="Ninject.Web.WebApi" version="3.3.1" targetFramework="net48" />
<package id="Ninject.Web.WebApi.OwinHost" version="3.3.0" targetFramework="net48" />
There's no specific redirect here for Ninject.Web.WebApi.OwinHost so I'm thinking that may be the issue or maybe one of the other libraries, but they never had redirects before and I've tried...
Get-Package MyApp.Api | Add-Bindings
(excuse the syntax here - it may be wrong as from memory)
...to add relevant bindings that were missing.
This was caused by a versioning issue with Nuget packages (This is why I don't use Ninject by choice anymore...)
I downgraded the WebApi package as follows...
<package id="Ninject.Web.WebApi" version="3.3.0" targetFramework="net48" />
So that it was in line with Ninject.Web.WebApi.OwinHost, cleaned, rebuilt and tried again and it all worked perfectly.
I would suspect that the Ninject.Web.WebApi.OwinHost package hasn't been updated yet and isn't compatible.
The package
<package id="Ninject.Web.WebApi.OwinHost" version="3.3.0" targetFramework="net48" />
was replaced by
<package id="Ninject.Web.WebApi.OwinSelfHost" version="3.3.1" targetFramework="net48" />
https://github.com/ninject/Ninject.Web.WebApi/issues/32#issuecomment-661886853
In my case I also needed to update Microsoft.AspNet.WebApi.Owin to version 5.2.7.

'Could not load file or assembly 'FSharp.Core, Version=4.6.2.0

I upgraded Visual Studio from VS2017 to VS2019. I opened a solution with both C# and F# in it. A C# unit test project references a F# .dll project.
The solution compiles fine but at run time, I get the following message
System.IO.FileLoadException: 'Could not load file or assembly
'FSharp.Core, Version=4.6.2.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)'
and the inner exception is
Could not load file or assembly 'FSharp.Core, Version=4.6.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
I have this in the unit tests app.config:
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.6.2.0" newVersion="4.6.2.0" />
</dependentAssembly>
and the unit test project has this in the packages.config
<package id="FSharp.Core" version="4.6.2" targetFramework="net461" />
Is there a missing reference I am not seeing?
Thanks
Bent Tranberg was right
In the test project, I changed the binding redirect to
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.6.2.0" newVersion="4.6.0.0" />
</dependentAssembly>
and it worked

Package Manager Console not working Visual Studio 2013

This is what I get when I open it, anyone had this issue before? Never happened to me:
Could not find file 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\typesv3.ps1xml'.
Could not find file 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Event.Format.ps1xml'.
Could not find file 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Event.Format.ps1xml'.
update: after adding those entries to devenv.config now I get:
There were errors in loading the format data file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\EXTENSIONS\AUEN3JAD.VIJ\Modules\NuGet\NuGet.Format.ps1xml, Error in file C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\EXTENSIONS\AUEN3JAD.VIJ\Modules\NuGet\NuGet.Format.ps1xml: '', hexadecimal value 0x13, is an invalid character. Line 311, position 36.
There were errors in loading the format data file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\EXTENSIONS\AUEN3JAD.VIJ\Modules\NuGet\NuGet.Format.ps1xml, Error in file C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\EXTENSIONS\AUEN3JAD.VIJ\Modules\NuGet\NuGet.Format.ps1xml: '', hexadecimal value 0x13, is an invalid character. Line 311, position 36.
Try adding these lines to devenv.exe.config file in the runtime section. It may work.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.PowerShell.Commands.Utility" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.PowerShell.ConsoleHost" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.PowerShell.Commands.Management" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.PowerShell.Security" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.PowerShell.Commands.Diagnostics" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
</assemblyBinding>
</runtime>
To do this, click Start, type Command Prompt or cmd in the Search box, right-click Command Prompt, and then click Run as administrator. If you are prompted for an administrator password or for a confirmation, type the password, or click Allow.
Type Command
C:\windows\system32>sfc /scannow
Adding the lines indicated above worked for VS2013, but then I had the same issue for VS2015, and it didn't work there. What worked there was Ed Vowles' comment here: https://github.com/NuGet/Home/issues/2836:
"I was able to resolve this problem by installing (or reinstalling) PowerShell from here https://www.microsoft.com/en-us/download/details.aspx?id=50395 (choosing this version: Win7AndW2K8R2-KB3134760-x64.msu for my windows 7 machine) and restarting."

Visual Studio 2013 Unit Test error: Could not load Microsoft.VisualStudio.TestPlatform.ObjectModel.dll

For some reason the unit tests from a test project in VS 2013 (w/Update 3) doesn't show up.
Could not load file or assembly
'file:///C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\
COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\
Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'
or one of its dependencies. Unspecified error (Exception
from HRESULT: 0x80004005 (E_FAIL))```
When checking the folder, the file is there.
My Chutzpah tests in another project in the same solution shows up. Couldn't find much info on this error when searching. Anyone had similar issues or know how to resolve this?
In my case , I have noticed in the Test Project's app.config file, that more than one assemblyIdentity where enclosed as part of tag, which should not be.
Improper configuration
<dependentAssembly>
<assemblyIdentity name="WindowsAzureTelemetryEvents" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
<assemblyIdentity name="WindowsAzureEventSource" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
</dependentAssembly>
Proper Configuration
<dependentAssembly>
<assemblyIdentity name="WindowsAzureTelemetryEvents" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WindowsAzureEventSource" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
</dependentAssembly>
After hours of trial and error, I noticed there was a app.config file in the test project for some reason. Removing this worked :)
Related answer: I was trying to be clever and use the XML directive thingey to comment out large sections of app.config that included other comments. Don't use <?... ?> directives in app.config.

Web Api: System.Net.Http version 2.0.0.0 not found

When I install the NuGet package for WebApi, it gives me version 1.0.0.0 of System.Net.Http, yet it references version 2.
I cannot seem to find version 2 for the life of me. When I download .net 4.5 I get System.Net.Http version 4.0.315.x, but I cannot use that because the Web Api assemblies refer to version 2.0.0.0.
Anyone know where I can find this version 2.0.0.0? I've tried the NuGet package manager, mvc4, .net 4.5, and nothing is giving me version 2.
Thanks in advance.
Add the below configuration inside your Web.config file under <system.web> node (assuming your app runs on .NET 4.5, targetFramework attribute is set to 4.5):
<compilation targetFramework="4.5">
<assemblies>
<add assembly="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
Also add the below one at the root level under <configuration> node:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
This should solve your problem.

Resources