So I have a WPF project and my interface in a different project than the main one. I went to reference System.Windows.Interactivity, but it would not work. Not until I added it as a reference to the main project as well...
This is the first time this has ever happened with any reference I have added. What makes this one so special?
EDIT:
By wouldn't work... This is the error.
{"Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."}
System.Windows.Interactivity.dll is not in the GAC, so .Net doesn't know where to find it.
By adding a reference to your main project, you make the build system copy the DLL to the output folder.
This lets the runtime find it.
Related
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.
Hi I am creating new project in visual studio using the following structure:
Now the way things will be referenced will be using the following structure:
Client projects will only reference Commercify.Product.Contracts
Commercify.Products will reference Commercify.Product.Contracts and Commercify.DataAccess.Contracts
Commercify.DataAccess references Commercify.DataAccess.Contracts
Infrastructure.Injector will be referenced only in client and will be used for registering dependencies
In startup I am calling the following code:
Assembly assembly = Assembly.Load(new AssemblyName("Commercify.DataAccess"));
When this code gets executed I get the following exception:
{"Could not load file or assembly 'Commercify.DataAccess, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.":"Commercify.DataAccess, Culture=neutral, PublicKeyToken=null"}
Now I am assuming that this is happening because Visual Studio does not seem to see that Commercify.DataAccess is actualy needed because its not referenced anywhere in the other projects. I had the exact same problem problem in a project that used csproj type of projects so it is not a dxsproj problem.
I had solved it by using a post build event.
I would prefer to have a more clean solution to this if there is one.
Can anyone tell me how to solve the problem?
You are loading dynamically a DLL, so Visual Studio doesn't has a clue that it needs to be copied.
Or you stick with the post-build events (I am working in an exact case like that and that's the best approach) or you add a reference to the project on the other projects, but it defeats the purpose of loading dynamically an assembly.
I've been struggling with this for days now. googling and trying diff things but with no headway.
I'm doing an MVC project but i need to use services from another project(web project). I did build the web project and referenced its dll in the mvc project. I can access members from the referenced project and everything compiles just fine.
However, the trouble is at runtime at the point where my code is calling a class of the refereced project and its throwing this "could not load type" whatever!
This is the line of code that is problematic
CurrentAgency = new AgencySystem().RetrieveByApiCode(agencyCode);
AgencySystem is in the referenced assembly.
but it keeps saying
"Could not load type 'EPaymentInvoicing.BusinessFacade.AgencySystem' from assembly 'EPaymentInvoicing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. "
Any idea why?
NB: The referenced project was build with vs2008 and the MVC project is in vs2010
Thanks(if u need more info pls i'd be glad)
The problem was with the assembly names.
Thanks to Saibal i was able to see that both projects had the same assembly name and the runtime was probably refering to the referencing assembly and looking for the AgencySystem tyoe there.
Changing the name of one of the assembly fixed my issue.
Check the platform type. It may be that the dll was compiled for x64 and your project is set for x86 or vice versa.
I don't think it's a platform problem as it should throw a BadImageFormatException in that case.
Does intellisense recognize the AgencySystem class? if that's true then probably you have referenced a newer assembly than the one that is copied in the compilation folder, so cleaning up the solution (and maybe deleting bin and obj folders) should fix it.
If intellisense is not recognizing the class then it probably doesn't exist.
I would recommend to add a version code and a strong name to the EPaymentInvoicing assembly specially if you are referencing it as a compiled assembly instead of a project.
I installed Monogame, and when trying to run a very simple hello world style game I get this exception. I understand that there are several posts on stack overflow regarding this error, but am still puzzled as to how to fix this. Do I need to uninstall .Net and reinstall a different version? If so, how do I do that?
A System.IO.FileNotFoundException was thrown.
Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
Here's a downloadable link to the Xamarin Project:
https://www.dropbox.com/s/q7quw26lg1etdts/MonoGameTester.zip
Such errors will occurs if you have reference to assemblies that do not ship with Xamarin.iOS. That's the case for System.Drawing.dll.
In your case it's likely because your project has references to both monotouch.dll and MonoMac.dll and that's not gonna work.
You need to build separate projects for each target, i.e. one for iOS (monotouch.dll) and one for OSX (MonoMac.dll).
From each project you can share source code and/or assemblies (for shared logic). Both projects also need to include platform specific code and references.
You end up with a lot of shared code (in source or assemblies) with a few platform specific bits of code.
I ran into the same issue and above suggestion didn't worked for me, so I did the following :
Open you Project
Go to the Solution Explorer
Expand the Reference group
Delete the System.Drawing reference
Right click on Reference group
Add Reference
On the ".NET" tab, search for System.Drawing to add the right reference
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.