Mismatch in Assembly and Product Version - c#

I am trying to use Ajax control toolkit in asp.net website. I copied the dll from one of my previous sample project. It has the following details
Assembly Version – 3.5.40412.0
File Version - 3.5.40412.2
Internal Name: Ajax Control Toolkit
Language : Neutral
Product Version - 3.5.40412.2
When I add reference to this assembly, it appears as “AjaxControlToolkit-3.5.40412.2” in the reference list. When I run the solution, I get a FileLoadException:
Could not load file or assembly 'AjaxControlToolkit-3.5.40412.2' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I think the problem is with the difference in Assembly version and File version. Is it so? How can we overcome it?

Edit the web.config file to remove the reference, which is not required for normal operation:
1 - Open the web.config file in the root of your site
2 - Find the following line and comment it out():xxxxx-is your assembly name.
<add assembly="xxxxx", Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
3 - Save and close the web.config file and try again
Ref Link : http://manual.aspdotnetstorefront.com/p-1118-could-not-load-file-or-assembly-microsoftwebservices3-version3000-cultureneutral-publickeytoken31bf3856ad364e35.aspx

Related

Testing.fakes error when I try to debug my C# app

I have a solution with 5 projects, one of them is a unittest and another one is an API Rest (donno if this is relevant hehe) . The problem I have is that when I added this unittest, I couldn't debug again my API, all the time a ' System.IO.FileNotFoundException' appears and I can't do nothing.
How could I fix this problem?
I tried removing all references via Visual Studio but still it is not working.
Could not load file or assembly 'Microsoft.QualityTools.Testing.Fakes, Version=12.0.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)
Thanks!

Could not load file or assembly 'Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=myKey' or one of its dependencies.

After running an ASP.NET C# application with SQL SERVER version 2012, I get the following error message:
An error occurred during local report processing.
The definition of the report 'C:\inetpub\wwwroot\psla\Reports\PD Listing Report - Per ED.rdlc' is invalid.
An unexpected error occurred in Report Processing.
Could not load file or assembly 'Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
What could be the cause? I have tried searching the net and there are references to version=11.0.0.0 but there are no references to version=12.0.0.0 for 'Microsoft.SqlServer.Types'. Reviewing the reference Manager for visual studio 2015, I was only able to find up to version=11.0.0.0.
In your Package Manager download the 12 version from Nuget
https://www.nuget.org/packages/Microsoft.SqlServer.Types/
Also see that entry for this is backward compatible in web.config
In your references folder right click and set copy local = true
It appears that some library in your project is referencing Microsoft.SqlServer.Types, Version=12.0.0.0 but .NET runtime cannot find it at execution.
On the web server, where the application is running, make sure that there exists a following directory: C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Types\12.0.0.0__89845dcd8080cc91\
Also make sure that this directory has the file Microsoft.SqlServer.Types.dll of version 12 (12.0.2000.8). Different versions of the file can be downloaded from https://www.nuget.org/packages/Microsoft.SqlServer.Types/

Load assembly from local directory and not GAC

I am trying to write a 'hello world' application with a dependency to an assembly of a CAD software (SpaceClaim). I add the assembly SpaceClaim.Api.V12.dll to my references and build without problems. When I try to run the application I get the following error:
Unhandled Exception: System.IO.FileLoadException: Could not load file
or assembly 'SpaceClaim.Api.V12, Version=12.1.11373.0,
Culture=neutral, PublicKeyToken=7210645d4d5e3a39' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'SpaceClaim.Api.V12, Version=12.1.11373.0, Culture=neutral,
PublicKeyToken=7210645d4d5e3a39'
---> System.IO.FileLoadException: Could not load file or assembly 'SpaceClaim.Api.V12, Version=12.1.8703.0, Culture=neutral,
PublicKeyToken=7210645d4d5e3a39' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040) File name:
'SpaceClaim.Api.V12, Version=12.1.8703.0, Culture=neutral,
PublicKeyToken=7210645d4d5e3a39'
(this error message is also discussed here)
After checking the GAC, I can see that there is an assembly with same strong name with the one I am referencing (Version=12.1.8703.0). However when I open these two with a disassembler (ILSpy), I see that they target different runtimes, the one I am referencing targets .NET 2.0 and the one in the GAC .NET 4.0.
I would like to ignore the one in the GAC and pick from the local directory the one that targets NET 2.0. Apparently, simply copying it into the same folder with the executable is not enough. From what I 've read so far here and here, in order to do this, one needs to 'remove the signing' from the assembly. I don't have much experience with .NET so I am wondering, is this something that I can do with 3rd party assembly and if yes how? Or what other alternatives I have? The two assemblies have the same strong name so putting them both in the GAC is not an option as far as I understand.

Google Api - System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http.Primitives'

I'm getting the following exception when trying to use the Google Auth API:
System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http.Primitives, Version=4.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
----> System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
The exception happens in Google.Api.Core.dll.
If I check the /Bin folder I can see Sytem.Net.Http.Primitives.dll in there and the version is 4.2.28.0.
I have tried updating the Microsoft HTTP Client Libraries NuGet package but that didn't help.
Is the problem something to do with a mismatch of .dll versions? If so how can I resolve that? Or is it something else entirely?
Double check if the assembly file is there in the bin folder and if its there, then try removing the reference and again add it to your project.
The version should be the same as expected. Also check on your web.config too for what it has about this particular assembly.
In your error code, I can see two different versions for the same file. Means probably, you are getting a clash between the existing assembly and the referenced assembly. Check you web.config for which version is referenced there and make sure you have the same version added to your project.
This link might help :
Could not find assembly System.Net.Http.Primitives

SolrNET - Could not load file or assembly 'HttpWebAdapters' when pulling from Nuget

I am using Nuget to get the latest version of SolrNET and StructureMap.SolrNetIntegration in my ASP.NET MVC project.
x.IncludeRegistry(new SolrNetRegistry(((SolrConfigurationSection)ConfigurationManager.GetSection("solr")).SolrServers));
When the above line of code is invoked I receive the following error:
Could not load file or assembly
'HttpWebAdapters, Version=0.3.0.0,
Culture=neutral,
PublicKeyToken=bc21753e8aa334cb' or
one of its dependencies. The located
assembly's manifest definition does
not match the assembly reference.
(Exception from HRESULT: 0x80131040)
I am concurrently upgrading to the latest version (0.3.0) as well as pulling solrnet from Nuget for the first time - previously this same code worked with the previous distribution downloaded directly from the SolrNET site. I can see that the issue occurs in the structuremap.solrintegration project when constructing the solrnetregistry, but I'm at a loss as to why
[FileLoadException: Could not load file or assembly 'HttpWebAdapters, Version=0.3.0.0, Culture=neutral, PublicKeyToken=bc21753e8aa334cb' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
StructureMap.SolrNetIntegration.SolrNetRegistry..ctor(SolrServers solrServers) in c:\prg\SolrNet\svn\StructureMap.SolrNetIntegration\SolrNetRegistry.cs:40
myproj.Core.BootStrapper.<ConfigureStructureMap>b__1(IInitializationExpression x) in C:\Users\jp\Documents\Visual Studio 2010\Projects\myproj\myproj.Core\BootStrapper.cs:66
StructureMap.ObjectFactory.Initialize(Action`1 action) +143
myproj.Core.BootStrapper.ConfigureStructureMap() in C:\Users\jp\Documents\Visual Studio 2010\Projects\myproj\myproj.Core\BootStrapper.cs:37
myproj.Core.MvcApplication.Application_Start() in C:\Users\jp\Documents\Visual Studio 2010\Projects\myproj\myproj.Core\Global.cs:131
Does anyone know if something has changed or if I am doing anything incorrectly?
Thanks
JP
The SolrNet.StructureMap NuGet package was incorrectly built. I already fixed it and sent a pull request to the NuGet team. EDIT: the fix is in.

Categories

Resources