The system can not find the dll - c#

I converted my console app to Class Library project so that I can use dll again for multiple project. I am getting an 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 system can not find the file
I've already tried the solution mentioned here: Could not load file or assembly System.Net.Http.Primitives. Located assembly's manifest definition does not match the assembly reference.
But no luck. Any suggestion

1- check if you are referencing an assembly which in turn referencing an old version of unity. for example let's say you have an assembly called ServiceLocator.dll which needs an old version of Unity assembly, now when you reference the ServiceLocator you should provide it with the old version of Unity, and that makes the problem.
2- may be the output folder where all projects build their assemblies, has an old version of unity.
you can use FuseLogVw application to find out who is loading the old assemblies, just define a path for the log, and run your solution, then check (in FuseLogvw) the first line where the Unity assembly is loaded, double click it and see the calling assembly, and here you go.
Your problem posted here previously: Could not load file or assembly or one of its dependencies
Please search before rising your question. Thanks

try right click -> Properties -> Build Action -> Embeded Resource should make it work

I will show you clearly the mean of Lucky Lefty. In Solution Explorer, right click on you .dll file and choose properties. The properties pane appears then on Buil Action option, you choose Embeded Resource. After that, you rebuil your solution.
You can view more information from here: http://www.codeproject.com/Articles/528178/Load-DLL-From-Embedded-Resource
Remember: Google search is your best friend.

Related

How to resolve "The located assembly's manifest definition does not match the assembly reference." error?

I downloaded source code for pdfiumviewer from git hub. I made changes to one of the projects in that solution.Then I added that project to my application and added reference of that project to one my application's project.I had to uncheck the Signing option for the PDfiumViewer project, as some of the dll in that project are unsigned.I am able to build the application successfully.But at run time when I create an object of one of the class of PDfiumviewer project.It gives me the following error:
Could not load file or assembly 'PdfiumViewer, Version=2.11.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
The version number of the assembly is correct.So, why am I getting this error?
The problem was that I had added reference of old unmodifed PdfiumViewer dll to another project.Hence, there was conflict between the two dlls (old and customized) at runtime.I removed the old dll reference and it worked.
Ive also encountered this issue, my scenario was thou that I had to add a reference from another solution into my project removing the reference was not an option - what worked for me was reinstall SQLclient from nuget package managerer on both solution. Hopes it helo someone else
The issue here is that you have a library that references v2.11.0.0 of the Pdfium library. This library could be an assembly that you built earlier, or another assembly that came from Pdfium that references this version of the library. When you built your version of the library you probably didn't use this same version number, and it wouldn't have been strong named correctly. To fix this, you can add an assembly binding redirect in your applications configuration file to redirect the offending library to your custom built one.
I wrote a program to fix this issue automatically: https://github.com/BackTrak/DependencyFixup/releases/tag/1.0.0.0
I know this question is old, but hopefully this helps out others!

One web application with two dlls. One dll is dependent upon the other. Why do I have to update both DLLs?

I have a web application that has two referenced assemblies in the form of DLLs. Lets call the DLLs Primary.dll and Secondary.dll. The Secondary.dll is dependent upon Primary.dll.
I need to add a feature to Primary.dll for use within the web application. This requires a new version. This new feature is not required by Secondary.dll. There are no breaking changes for Secondary.dll.
Now when a bit of code in Secondary.dll is triggered, I get the following error:
"Could not load file or assembly 'Primary.dll' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. "
Secondary.dll is looking for the specific version of Primary.dll
Is this solved simply by making the SpecificVersion="false" value in the Secondary.dll project file?
If not, I've thought of keeping the older version of Primary.dll in the GAC, this way Secondary.dll would find it there. But would like to avoid this if possible.
So now I'm stuck with having to rebuild and re-version Secondary.dll, with a reference to the updated Primary.dll, every time I make a change to Primary.dll for use by the web application.
Is there way to make it so I don't have to update Secondary.dll's reference to the new version of Primary.dll?
If changes are really not breaking, try this way:
Check assembly attributes of your Primary.dll and get rid of signing and auto-generated assembly version (change 1.0.0.* to 1.0.0.0).
If it doesn't help, open Secondary and Primary with ILSPY utility and check what the exact the reference to the Primary.dll, and compare it to the actual full assembly name of Primary.dll. Also check references to your other dll, that could be referenced in both Primary and Secondary.
If it doesn't help, possible you have several files of Primary.dll assembly with different metadata and assembly loader loads the wrong one. Just find and delete wrong files or use Fusion Log Viewer utility to explore assembly binding. Maybe, this can help.
To make the investigation more simple, use simple almost empty ConsoleApplication with reference to Secondary.dll to play instead of web application.

MVVM Light Issue

I have both GalaSoft.MvvmLight.Extras.WPF4 and GalaSoft.MvvmLight.WPF4 referenced in my project, however if I declare the following namespace (which does not appear in the drop down list - neither do)
xmlns:Command="clr-namespace:GalaSoft.MvvmLight.Command; assembly=GalaSoft.MvvmLight.Extras.WPF4"
I get the following error
Error 1 Unable to load the metadata for assembly 'GalaSoft.MvvmLight.Extras.WPF4'. This assembly may have been downloaded from the web. See http://go.microsoft.com/fwlink/?LinkId=179545. The following error was encountered during load: Could not load file or assembly 'GalaSoft.MvvmLight.Extras.WPF4, Version=3.0.0.30137, Culture=neutral, PublicKeyToken=e80d33351f9dc0a2' or one of its dependencies. The system cannot find the file specified.
You downloaded the DLL from the web, and so it is marked (via NTFS alternate data streams) as such. Executables and other binaries are blocked by the system automatically in this case.
You need to unlock the file. Assuming you got it from a legit source (I'd assume not) you simply right-click on the DLL and click the "Unblock" button at the bottom of the form.

C#: cannot find assembly file

I am getting an error back from a DLL saying it cannot create an instance of one of classes in my solution because it cannot find the assembly file.
If I am debugging a solution, do I need to put a copy of certain assembly files in other locations?
EDIT:
In my compiled solution all the DLLs (including the proprietary ones) all go in the app directory and it works fine. But I am trying to work out where the files should do in order to debug the solution.
Put the assembly in question in 1) the same directory, or 2) in the GAC, or 3) use AssemblyBinding to define the specific path that the .NET framework.
MSDN link: using AssemblyBinding to define the referenced assembly path
I think you have forgotten to add reference of the assembly to the project.
Add the reference, and try again.
Read more here -> http://msdn.microsoft.com/en-us/library/7314433t%28VS.80%29.aspx
If they are in your references list, try right-clicking the problem reference in the solution explorer and selecting "properties". There is one property called copy local. Make sure that is true. Then when you build, a copy of that dll will be in your bin folder.
You can add an event handler to AssemblyResolve to find out which library it tries to load. Some sample code and ideas can be get from this question.
Update
To find out, what is the best place for your project you should take a look into How the Runtime Locates Assemblies guide. Also to get a live view about where the framework searches for your needed dll you can use ProcessMonitor to see where it tries to catch it.

Could not load file or assembly error

Can anyone help me figure out what the problem is. I am trying to start up a C# winformsa app in visual studio and i keep getting this error:
Could not load file or assembly, Foo.dll version1.93343 or one of its dependencies
The system can't find the file specified
vs 2005, C# 2.0
any help
Typically it's about one of your references' reference, possibly deep down in the dependency tree. What I usually do is, fire up Sysinternals Process Monitor (http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx), filter by process name, and run the app. It's typically fairly easy at this point to sift through the FILE NOT FOUNDs and locate the offending missing reference.
Fire up Fuslogvw.exe and inspect which assembly (or reference) can't be found.
This is the key part: "or one of its dependencies"
I've often found that the assembly dll file that can't be loaded looks fine. However one of its dependencies (another assembly dll) does not exist or has been moved.
When the CLR loads an assembly it will also check that all of that assemblies dependencies exist. In XCopy deployment this normally means you need all the dependency assemblies in the same directory as your application exe.
Try loading the winforms executable into Reflector and under "yourApp.exe" expand the References node to see what the other referenced types are.
You must have a reference to Foo.dll somewhere and it can't be located (duh). Do you see a reference in the solution window? You can right click that and select "properties" to look at the path.
Do you see an exclamation mark on a reference in visual studio's solution explorer ?
If so, then you need to remove it then add it again.
Worth checking your global web.config hasn't got a reference to that assembly

Categories

Resources