I have C# project created in VS 2008. I have referenced another DLL to it and kept Copy Local option to true. When I am doing a first rebuild, it fails with "could not load file or assembly" message and then if I build without any changes it builds fine.
In the background, rebuild cleans bin directory and build solution file at this time refrenced DLL gets deleted so it throws exception. On next build referenced DLL remains in bin directory and project builds successfully.
Now I want to know how can I resolve issue and ensure succesful build each time.
Thanks
If the referenced DLL noes not change (for example if it's a third party component) then a neat trick for this is to change the attributes of the referenced DLL in your BIN folder to read-only and it will not be deleted by the VS Clean function.
Related
So I created a project in my build environment and it includes references to external DLLs. After adding the references you can see the references in the .csproj file. After checking the code in, the code was checked out on the build machine. Attempt to build, we get errors about missing references to DLLs specified in the references. But the DLLs are there.
Next, we open the project in the VS GUI. Click the references tab, nothing. Added the references again by hand. Save and close VS and kick of the build. It works just fine. We do a diff of the directory tree containing the project and there are no changes. So VS is storing these references somewhere that isn't the .csproj file. Where?
Not being able to find this will make change management difficult.
I am getting this error:
Could not load file or assembly, system could not find the file specified.
Images:
http://s30.postimg.org/4x936f6ch/error2.png
http://s17.postimg.org/41ta9aaj3/errro3.png
I have a solution built in .NET 4.0
In it I have projects that act as plugins. They use dlls and the issue is that one of the solutions projects dlls is being called, and that references the dll that is causing the issue.
I get no error when rebuilding etc just when the program gets to the part where it uses the dll that references this one.
I have also made sure that in the projects bin folder that it has the dll that it is complaining about.
I have opened the dll in reflector and I don't think it has any issues.
COuld someone point me to the next step to try with fixing this issue?
Thanks!
Couple of tips - hard to know if they'll help you:
Open the csproj file(s) in a text editor and see where the dlls are being referenced (GAC possibly)
If it's a signed assembly, make sure you've got a signed copy (if you've built an Open Source project yourself the signing will be lost)
Look at the references in Visual Studio - do you have Copy Local set to True and Specific Version set to False?
Look at you're App.config or Web.config - is there a binding redirect that failing to load
I remember reading a post about assemblies not being able to be unloaded - probably not an issue on this one but I think the trick was
to load the DLL in a separate AppDomain to keep it isolated - loadable
and unloadable.
I have been working on an ASP.NET project for months now without issue. Recently my computer crashed mid compile and now when I load and run the project I get 'Could not load file or assembly 'Ionic.Zip' or one of its dependencies.'
Thinking it was an issue with that particular DLL, I removed it as a test only to have the project say it could not load another referenced DLL, etc etc, until I had no references left...
Any ideas?
If nothing in the code has changed. "Build->Rebuild Solution" should do the trick (implicitly cleans and builds).
If this does not work, do "Build->Clean solution" and go delete all generated build folders (default bin and obj folders). And then try build and run.
And if it still does not work, the code has changed and dependencies are really missing.
Using NuGet and packages are missing perhaps?
I tried everything but NuGet, I didn't use it to get any of the references before.
In the end I had to check in all my changes to TFS, delete the project from my workspace and computer, and then reload it from TFS. Seems to have worked. Something must have been damaged in the project file.
I'm writing a WebService that references another managed DLL which then uses a third-party DLL. When I start debugging my WebService I get the following error:
Could not load file or assembly 'AForge.Video.FFMPEG.DLL' or one of
its dependencies.
As recommended in many other posts, I tried these steps:
Changed from AnyCPU to x86
Copied all DLLs to %system32% directory
But had no success so far. Any ideas?
Thanks, Matthias
Could not load file or assembly 'AForge.Video.FFMPEG.DLL' or one of its dependencies.
You are either copying the file(s) to the wrong place or not copying the correct files.
Get to the bottom of this by downloading Dependency Walker
You can then drag AForge.Video.FFMPEG.DLL into the application and it will tell you what is missing.
Also, determine the base directory for your application to ensure you are copying the files to the correct folder at runtime. You can do this by writing System.AppDomain.CurrentDomain.BaseDirectory to the console (or add it to your watch)
Also see this
I re-engineered the project structure in VisualStudio to get rid of the dependency to AForder.Video.FFMPEG.DLL. That helped. I found no other solution so far.
I'm trying to debug my dll and I have the pdb file next to the dll and I still can't step into the method. What else am I missing?
The version of the assembly loaded in your application is not the version that is loaded in Visual Studio.
If both projects are in the same solution, ensure you are adding a reference by using a Project Reference rather than browsing to the /bin folder. In cases like this, you may browse to the /bin/release version, then set the Build to Debug, causing the problem you are experiencing.
If projects are in two different solutions, ensure the solution you wish to debug is cleaned and rebuilt, and then re-add the reference to the fresh assembly in the running project.
Make sure the PDB is the latest build. Also make sure the PDB is in the same folder as the EXE you are running.
As Travyguy9 mentioned make sure that you have rebuilded whole solution. Also from time to time I also can't debug and then I have to close VS and open it again.