Could not load file or assembly DLL - c#

I am trying to implement A DLL into an existing project. I am getting this Error:
{"Could not load file or assembly 'Aspose.Words, Version=21.12.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56' or one of its dependencies. The system cannot find the file specified.":"Aspose.Words, Version=21.12.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56"} System.IO.FileNotFoundException
Every time it try to run the method that creates the Aspose(dll) object it goes straight to catch, with this message. But it's odd though because when i Run the exact same code with the exact same package and path, it works just fine in a new standalone program.
Any tips ?

The problem seems quite straightforward, windows can't find the .dll. So probably the reference points to nowhere. Can you try to debug and see where exactly does it look for it, in what location? Then open file explorer and verify if it actually exists there.
It might look for the .Dll in project or in Global Assembly Cache. Try cleaning the cache and try again.

Related

Why do this occurs "Could not load file or assembly.." in C# class Library

I'm newbie to .net projects. Although I was able to code in c# & use it's frameworks, Some times I face exceptions which I really didn't get any proper resource/suggestion to modify or rectify them. Hope I would get clear this time.
The exception which I faced is as follows :
Could not load file or assembly 'Microsoft.AspNetCore.Cryptography.KeyDerivation, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
I'm really confused with such type of exceptions. What's the reason for those & how we needs to cross check to clear those ?
Here is what I did install: "Microsoft.AspNetCore.Cryptography.KeyDerivation" from nuget console with version 2.2.0.
My installed packages list image :
The main reason for this type of error is a result of your output folder. Take a look at where your binary outputs were placed. Inside of that folder (usually your .exe or .dll output, not sure what kind of .NET project you're writing), you should also have all of your dependency dlls. In this case, the dll related to Microsoft.AspNetCore.Cryptography.KeyDerivation is missing. So when you go to run your executable, it complains "Could not load file or assembly KeyDerivation" because it couldn't find it.
To resolve this issue, double check your project's references and that there are no issues with the Microsoft.AspNetcore.Cryptography.KeyDerivation reference (what I mean is, make sure there are no yellow exclamations or other icons showing up next to this reference in your Solution Explorer). If you have any issues, remove the reference, then add the nuget package again.

What could make the "System.ComponentModel.Composition.dll" unregister from my system

I have an C# application that uses some custom lets say some.dll and the dll references the "System.ComponentModel.Composition.dll". The application was working fine until I rebuilt the some.dll and replaced it with the original dll in my system.
Now when I try to start the application it is giving the error "Exception ::Could not load file or assembly 'System.ComponentModel.Composition.resources, Version=4.0.0.0, Culture=en-NZ, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified"
The error persists even if I replace the new dll with original one.
I suspect that the System.ComponentModel.Composition.dll has been unregistered. Can anybody explain what could be the problem?
The issue was the application is trying to read all the .dlls placed in a folder and when I replaced the existing some.dll, I renamed it as some.dll.back(or some.back.dll, I don't exactly remeber) and kept it in the same folder. The application considered the some.back.dll and tried to load it and got this error. I deleted the some.dll before replacing my own version of the some.dll and it didn't show any error, confirmed that it was the root cause.

Could not load file or assembly 'System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKey

After doing push from git server I got this error when I build and open my project:
Could not load file or assembly 'System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=******' or one of its dependencies. The system cannot find the file specified.
The project is working pretty well with the same code in a different computer.
Problem
The error is a file not found, like the one I helped out with the other day:
Could not load file or assembly .. The system cannot find the file specified.
Troubleshooting
Open ProcessMonitor and run it when VS won't let you build your solution and throws the error. Stop the trace when it fails and investigate ProcMon's (Filemon) log to see where the IDE is looking for the DLL it cant find.
Solution
Put the DLL where its expected to be found (this will hopefully sort out the VS library referencing failure).
Also try:
disable Resharper
restart VS
clean & rebuild
I found nuget or some other update can bump the System.Web.MVC version to 4.0.0 unintentionally. So just check the dll that you have in your bin folder (or wherever the reference points) is of the same version specified in your web.config.

adding dlls to a solution and referencing them

I am developing a .net solution. Due to certain complications, I have been asked to add dlls to the solution and then reference the dlls from within the solution.
It works fine on the local box , and builds perfectly on TFS Build server,
but when I run it on the server after deploying , I get a run time exception saying :
Could not load file or assembly 'Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Would you know what I should be doing at this point ?
I can provide you more detailed info if needed.. please let me know.
It seems like you need to get Microsoft.TeamFoundation.Client.dll file,
then add it as a reference to your application
this is the dependencies you described:
Two possible resolutions
Set CopyLocal property to true so that when build is done local copy of dll is added.
Check reference folder has been checked in TFS or not. Sometimes it happens that reference folder is not added in TFS.

FileNotFoundException when using dll method

in Visual Studio I have a solution with several projects. In one project I added a reference to another project. All fine. I can see the namespaces/classes of the another project in autocomplete, etc.
When I try to do
OtherProjectNamespace.Class a = new OtherProjectNamespace.Class();
I'm getting this:
Could not load file or assembly '**OtherProjectNamespace**, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
There is no line, nothing, I tried try... catch around the new line and is not even catching the exception.
What could be the cause?
Thanks,
Carlos
Some possible directions:
Does the class you are trying to create have any dependency on a class in another assembly? If it does, try adding a reference to the third assembly.
Did the assembly get copied to the running directory of your application? Ensure that the Copy Local property of the reference is set to true.
If you still don't resolve the problem, use a tools such as Fusion Log View (comes with Visual Studio, run fuslogvw.exe from VS command line) to get the exact name of the file that was missing, and the locations from which the CLR tried to load it. Maybe this way you'll find another file that you need to copy.
Try this:
In the project references, change the "Specific Version" property to false. Right click on the project and select Clean. Then rebuild the project.

Categories