I wrote a windows form solution with 2 layers; one is DataAccess and the other is windows form.
I use Code first. If DataAccess Layer runs in the application console, there is no problem with the db. Create the schema and insert the data.
However, when I run the solution with Windows Form as the initial project and refer to DataAccess as a dll, I cannot build the database. It throws an exception.
I think that the app.config file is the problem, but if I copy the app.config file of DataAccess project to the windows form, it does not resolve the problem.
the config file of DataAcces layer:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
the exception:
"first exception for 'System.Data.Entity.Core.ProviderIncompatibleException' in EntityFramework.dll
Aditional Information: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct."
Inner Exception:
{"The provider did not return a ProviderManifestToken string."}
The problem could be due to Error in connection string
or in my case it was that
SQL server service was not running
manually start the SQL service through SQL SERVER COnfiguration Manager
after a long deep search, i found that solution was "clean the solution".
we are using enterprise library 6.0- exceptional handling block and configuration console for defining policy.
The following code has been generated in app.config file for the defined policy
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<exceptionHandling>
<exceptionPolicies>
<add name="DataAccessPolicy">
<exceptionTypes>
<add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="ThrowNewException">
<exceptionHandlers>
<add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
exceptionMessage="An occured in the data
access layer.
Please Contact the
Admin with Error Id { }."
replaceExceptionType="Mindtree.Azure.PaymentGatewayExceptionHandler.DataAccessException, Mindtree.Azure.PaymentGatewayExceptionHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
</exceptionPolicies>
</exceptionHandling>
</configuration>
I have the following code in my catch block, i am defining manager using configuration source factory and setting the exception manager
IConfigurationSource config = ConfigurationSourceFactory.Create();
ExceptionPolicyFactory factory = new ExceptionPolicyFactory(config);
ExceptionPolicy.SetExceptionManager(factory.CreateManager())
bool rethrow = ExceptionPolicy.HandleException(ex,"DataAccessPolicy");
if(rethrow)
throw;
DataAccessPolicy is defined in the app.config file which uses the repalce handler
but the following error is thrown when debugging
The configuration section for Exception Handling cannot be found in the configuration source.
Any Help would be appereciated. Thanks in advance
I'm working on a program that uses the Google API. However every time I run my program, it I keeps getting the following error:
Could not load file or assembly 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f711d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
I'm using Visual Studio 2012 express. I've tried following this link and looked through many forums, but none seem to work. The main problem seems to come from the DLL file "Google.Apis.dll" which I referenced, and it references System.Net.Http.Primitives v1.5.0.0. However the version my program references is 2.2.13.0. I've tried having the program reference v1.5.0.0 instead (I manage to find the dll along with the source code of Google.Apis) however this only caused another problem in which I needed a more recent version of System.Net.Http.Primitives.
I'm been trying find a way to work around this, however I can't seem to find anything that works. Thank you for time.
I ran into the same issue with the Google API's. The main issue here is if you install the Microsoft Http Client Libraries it puts in your project an updated version of the System.Net.Http.Primitives DLL. The web.config assumes you are still using the default version of 1.5. There are two things that need to happen to fix it:
First: Update to the latest versions of Google API and Microsoft Http Client Libraries. You can install the updates via NuGet. Right click on your website, click "Manage NuGet Packages", select Updates on the left. At the time of this post some of the Google API's are prerelease only. You can install them via NuGet by selecting "include prerelease" on the top left of the update screen.
Second Update/add a dependentAssembly into your web.config. To do this you need to know the version of the System.Net.HTTP.Primitives.dll that was installed. Look in your bin directory within Windows Explorer. Find System.Net.HTTP.Primitives.dll, right click on it, select properties, and click the "Details" tab. Note the version located there. At the time of this post mine was 4.0.10.0.
Then add/update a dependentAssembly section for the correct version.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
What worked for me was to simply install the "Microsoft Http Client Libraries" from Nuget.
Add following to your web.config (app.config):
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.13.0" newVersion="4.2.13.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
For me it worked the following:
On Visual Studio (2012) > Tools > Nuget Package Manager > Package Manager Console.
On top of package Manager Console I have
Package Source: nuget.org
Default project: the project that requires the System.Net.Http.Primitives
Watching inside the project file (yourproject.csproj) with an editor I read which version is needed (in my case was Microsoft.Net.Http.2.2.28)
So I went to https://www.nuget.org/packages/Microsoft.Net.Http/ and I clicked on my version under "Version History" (scroll a bit the page if you don't see it).
After choosing the version you copy the suggested command - in my case it was:
Install-Package Microsoft.Net.Http -Version 2.2.28
but if you need the latest version is just this:
Install-Package Microsoft.Net.Http
and you paste it on your Visual Studio Package Manager Console previously opened as I described before. Execute the command.
In the project under the references, System.Net.Http.Primitives is now updated.
I've had a similar problem.
Try to update nuget (tools/extensions and updates...)
Solved that and some other problems for me.
/Jonas
We were having the similar problem.
But in my case, the solution of modifying the app.config by Paul didn't work.
The reason is I am using it as a plugin inside another application. So it considers that application's configuration file.
So we got the Google api code from GitHub and built the Google.Apis.Core library after removing the dependency of System.Net.Http.Primitives. Then we used that dll which solved our issue.
I ran into this problem when I released my code that uses Google.Apis.Drive.v2 (v1.9.2.1860) to the company I work for. I gave them the exe and all of the DLLs that Visual Studio (and NuGet) generated, and they got the error. I never got the error.
The fix was easy (once I figured it out): When installing the api from Nuget the file 'assemblyname.exe.config' is automatically generated in the output (aka, Debug or Release) folder. All you have to do is include that file when you are running the assembly somewhere other than the folder it was generated. Here's the code for that file for me:
<?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.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.29.0" newVersion="4.2.29.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
This is basically Paul's "second" fix but it's automatically generated by the package manager. The issue for me was when I tried his "first" fix by updating to Google.Apis.Auth and Google.Apis.Core (v1.9.3) it made things worse. I'd get the same error except now it was for "Google.Apis.Core" was the wrong version (although that probably could have been solved as well by including the same .exe.config file.)
Hope this helps someone, I know this thread is pretty old, but it's the one that a quick Google search led me to.
Edit: Forgot to mention, this is relevant to a console application targeting .NET 4.5. Some of it is probably still relevant to other .NET targets or ASP.NET but I don't know for sure. Your mileage may vary.
The above answer about assemblybinding are correct, but you should NOT touch the machine.config.
The assemblybinding must be set in the config file of all of the EXECUTABLE assemblies of your project (.exe.config) who reference your library, and not in the library assemblies (.dll.config)
NuGet made the following change in Web.Config
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.22.0" newVersion="4.2.22.0" />
</dependentAssembly>
to
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.28.0" newVersion="4.2.28.0" />
</dependentAssembly>
This was following install and subsequent removal (by version control revert) of this package https://www.nuget.org/packages/Microsoft.AspNet.WebApi.MessageHandlers.Compression/
Somehow the popular answer by Paul Lemke was not working for me.
The project is a webforms application that started with .net v 2.0 and has been upgraded to .net version 4.5
I updated the packages and nuget created the correct dependentAssembly/bindingRedirects.
As per some of the comments, it probably is not the best idea to change your local machine.config file.
Apprently I had an attribute in my web.config file that was causing the app to ignore the bindingRedirects.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
I removed that xmlns attribute and it started working.
Was able to resolve this pretty easily. Just opened up the Nuget Package Manager and updated the Microsoft ASP.NET Web API 2.2 Client Library package. This updated Microsoft.Net.Http to the newest version which resolved the issue with the System.Net.Http.Primitives Assembly from being able to be located. Hope this helps!
In my case I was referencing the NuGet packages from a class library. NuGet fails to inform us that the class library's app.config is completely ignored and we have to manually copy its contents to the .exe's app.config.
I had a similar issue with PowerShell scripts for TFS 2017. The scripts called .NET code to perform custom actions during build processes. I kept getting errors about dll version conflicts.
I was unable to resolve the issue until I implemented a hook into the AppDomain AssemblyResolve event as per this answer: Making binding redirects work for office add-ins
This solution forced the process to use dlls from the current path. I know this is somewhat of a hack, but I had read that when running PowerShell, you cannot always use binding redirects, which is what I originally though I could try: https://github.com/google/google-api-dotnet-client/issues/555
Install-Package Microsoft.Net.Http -Version 2.2.22
This version has that dll \packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Extensions.dll
In my case, Nuget automatic add following to web.config
<runtime xmlns="">
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.22.0" newVersion="2.2.22.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.10.0" newVersion="2.1.10.0" />
</dependentAssembly>
</assemblyBinding>
But I still got the above error Message, finally I figure it out. You have to copy those tags to the machine.config file located at C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config.
To find the tag of "runtime" on machine.config, replace or add(if there is no such tag) it with your tags from your web.config (the ones I listed just above).
After installing and configuring Reporting Services on a virtual site with a ASP.NET MVC running on the root folder, I get this "Error" :
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'Spring.Web' or one of its dependencies. The system cannot find the file specified. (C:\Inetpub\wwwroot\blc\web.config line 171)
Source Error:
Line 169: <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 170: <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 171: <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
Line 172: <add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate21"/>
Line 173: </httpModules>
Source File: C:\Inetpub\wwwroot\blc\web.config Line: 171
Does anyone have any idea on how to fix this ?
Thanks guys
Make sure Spring.Web.dll is in your bin folder?
I see an entry in ccnet.exe.config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NetReflector" publicKeyToken="2f4dd8b32acbcd8e" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.120" newVersion="1.1.2009.1004" />
</dependentAssembly>
</assemblyBinding>
When I first installed the service, I had no errors, but after following this tutorial
link text
I am getting this error when I try to run the service or CCValidator.
Could not load file or assembly 'NetReflector, Version=1.1.2009.1004, Culture=neutral, PublicKeyToken=dbcd6104b72f39b2' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Can anyone point me in the right direction?
Thanks,
~ck in San Diego
There was issue with cc.net 1.4.4 and the vsts plugin where I had to compile the plugin from source against the netreflector version 1.1.
However this issue has been fixed. Just install the latest version of cc.net, 1.4.4.83 (i.e. 1.4.4 SP1) and use the ccnet.vsts.plugin.dll 1.3.1.
I would use backup the ccnet.config and then just unzip on top
Get the binary zip distribution