I have a .Net 4.5.1 application using Web API 2 and running in my local Azure Emulator. I have some OWIN components installed and in my Startup.cs file within the Configuration(IAppBuilder app) function I have the following code block and the last line causes an exception:
HttpConfiguration httpConfiguration = new HttpConfiguration();
WebApiConfig.Register(httpConfiguration);
app.UseWebApi(httpConfiguration);
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
This line is causing an exception "Could not load file or assembly 'System.Web.Cors, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies."
I'm having trouble figuring out why NuGet didnt' install this if it is a dependency. Additionally I'm not able to find a corresponding dll already installed to add a reference myself, nor the correct NuGet package to install to provide said dll.
Has anyone experienced a similar issue? If so, perhaps you could point me in the right direction.
This is surely coming cause of your DLL version is different OR DLL is missing on that environment.
Few steps you require to check:
Cors DLL should be there in your BIN directory [On Azure]
If it's there then Version of DLL deployed on server and your local both should be same. [You can check in properties]
<dependentAssembly> <assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.1" /> </dependentAssembly>
Your new version could be your DLL version which are available into the BIN directory.
Have you tried Microsoft.Asp.Net.WebApi.Cors at nuget? https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Cors/5.2.2 It's not a dependency for the Cors package because it's for webapi and the only microsoft.owin.cors dependency is on the base microsoft.asp.net.cors (other than the owin packages).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With