This is the weirdest thing. I have a solution with multiple Class Library projects (all .Net Framework 4.7) and multiple unit test projects to test those class libraries. Once in a while I upgrade my NuGet packages to keep them up to date, and some of those upgrades introduces an app.config file to the test-project. Once that app.config is introduced, the tests are not longer discovered by Visual Studio, and therefor they are no longer ran after each build. Considering a failed test is a trigger to correct code, this created a scenario where we would introduce code that failed the unit tests, but because we relied so much on automation, we assumed it succeeded.
In summary:
- the existence of an app.config makes VS2017 not discover the tests in the project containing the app.config, even if the app.config is completely empty. Only deleting the config-file will make VS2017 rediscover the tests
- Everything in the solution is targeting .Net Framework 4.7
- All Nuget Packages are updated, including the MsTest Adapter and TestFramework
- The app.config files are filled only with assemblybinding entries, forinstance:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Found the perpetrator, thought I'd share in case anyone else runs into this. After adding the System.Runtime NuGet package to my test-projects, the tests got discovered by VS2017.
Related
This is usually a pretty simple issue as the error is quite clear but for some reason not in my case.
Essentially we have a few split up projects and the nuget packages gets installed in the shared project with the rest of the websites making reference to them. Instead we reference them in the web.config file and on build they get put in the bin folder.
In my current issue we are referencing Abstractions 3.1.5.0 yet now its complaining that it wants 3.1.0.0
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.5.0" newVersion="3.1.5.0" />
</dependentAssembly>
I have tried the following.
Actually installing the nuget package (v3.1.5) but get the same error
Added the following in the project file
<PropertyGroup> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> </PropertyGroup>
Funny thing is that when I installed v3.1.0 I got an error saying that its looking for 3.1.5.
This is also working fine for every other project except this one
A malformed web.config caused the issue. This might have happened during a merge.
I had sections that had 2 references within a dependentAssembly tag, once I separated them, deleted bin and obj folders I got it working again.
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Logging" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.5.1.0" newVersion="6.5.1.0"/>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.14.0.17971" newVersion="2.14.0.17971"/>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
When calling the System.IO.Compression.Zipfile.CreateFromDirectory, I am met with the following error :
However, my project does contain the first version of the assembly mentioned in the error (seen in the screenshot below).
After searching around, I saw that this error could arise from not having the System.IO.Compression.FileSystem assembly, which this project has :
I tried using / removing the System.IO.Compression.Zipfile assembly (which I found out is just a "link" to System.IO.Compression.FileSystem), changing System.IO.Compression versions, but nothing worked.
This project runs under the .NET Framework 4.6.1.
Does anyone have an idea of how to troubleshoot this one ? Thanks !
In my case I added the following to web.config runtime/assemblyBinding node:
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
You can manually add the following binding redirect in your application's config file:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression.ZipFile" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Change this
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.Compression.ZipFile.UseBackslash=true" />
</runtime>
To
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.Compression.ZipFile.UseBackslash=false" />
</runtime>
We are developing a new WEBAPI, which requires dll Package installation : “Microsoft.AspNet.WebApi ” version 6.0 for assembly reference. As a part of this Newtonsoft.Json.dll is referenced to the project.
Our Application already has “Microsoft.AspNet.WebApi ” version 4.5.
I even tried to use the older dll, but its not compatible with reset of the binaries in the WebAPI project.
If I override the older version with the newer version what could be the possible impact. I have used the old version in the Exception Handling wrapper classes.
I've lost a good bunch of brain cells fighting similar issue for Owin-based WebAPI project. "Solution" I use is dependencies redirection in app.config file. Here is file from my solution, you can correct it to your needs.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I added the Odata v4 package to my API, I noticed that it updated my Microsoft.AspNet.WebApi package to 5.2.3 version. But when i try to use
odata builder configuation in my WebApiConfig it showing error like
'Could not load file or assembly 'System.Web.Http, Version=5.2.2.0'.
config.MapODataServiceRoute("odata", null, GetEdmModel(), new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));
I searched this version(5.2.2) in my project but every thing is 5.2.3 and I updated all the packages too to solve this issue but failed.
Copy to Local property also true for System.Web.Http dll.
Any idea?
Visual studio solved this for me. The version conflicts are shown as warning and when I clicked it automatically added the binding redirect to my web config.
https://msdn.microsoft.com/en-us/library/2fc472t2.aspx
The binding redirect that solved my issue is,
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31BF3856AD364E35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
Well this is not "real" solution but a workaround:
I have changed the machine.config and replaced <runtime /> with
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
so I works but if you have other web sites running...
I'm trying to get SignalR working in an MVC5 project with individual accounts.
The MVC project has by default Owin 2.0.0 and all of the Owin.* components are also 2.0.0.
So I used NuGet to get all the SignalR packages, it automatically resolved dependancies and downloaded v 2.0.2.
The project throws an error on startup with the following message:
Could not load file or assembly 'Microsoft.Owin, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
I also tried upgrading Owin to 2.1.0 but that didn't help either.
Has anyone faced the same problem and what was the solution?
You can update this references to the lastest version I found (now is 2.1.0):
Install-Package Microsoft.Owin -Version 2.1.0
Install-Package Microsoft.Owin.Security -Version 2.1.0
And make sure your Web.config have these binding redirects for version 2.1.0:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Or you can update this references to version 2.0.1:
Install-Package Microsoft.Owin -Version 2.0.1
Install-Package Microsoft.Owin.Security -Version 2.0.1
And make sure your Web.config have these binding redirects for version 2.0.1:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Perhaps you need a binding redirect in your .config
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
In my case when I hosted my WCF service that has SignalR functionality in IIS and when I go to my IIS manager and to my application where I hosted my service right click svc file and click Browse, I was getting this error. So I did the following
In my Visual Studio, Tools -> Library Package Manager -> Package Manager Console
I made sure I selected my Website project that hosted my WCF service and gave below two commands one after another
uninstall-package Microsoft.AspNet.SignalR
install-package Microsoft.AspNet.SignalR
After this I just re-build my solution. Went to IIS manager and to my application where I hosted my service right click svc file and click Browse, I was able to see my service running in IE.