Couldnot load file or assembly for Coded UI - c#

I'm getting an exception while debugging my code in VS2010 premium. Its about version of the dll that I'm using
Microsoft.VisualStudio.TestTools.UITest.Extension.IE.Communication.Interop
Couldnot load file or assembly
Microsoft.VisualStudio.TestTools.UITest.Extension.IE.Communication.Interop
version=9.0.0.0
Which version of the dll is to be used and where it is available?

We are getting this exception because the dll is missing in the
solution bin folder. If you are debugging the solution keep the dll
under the folder Debug, or else release then keep it under the folder
Release. If you are adding reference by using the option 'add
reference', may be it won't be in these folders, so it happens to get
this exception. So if you are getting this exception make sure that
dll is added properly.

Related

System.IO.FileNotFoundException: Could not load file or assembly 'X' when running the application

I am developing an extension for Autodesk Vault but recently I got the following error when I try to set the references of the programm DLLs to Copy Local = false:
System.IO.FileNotFoundException: Could not load file or assembly 'X' or one of its dependencies
Oddly enough it works when I set the attribute Copy Local to true for some reason.
FYI: The DLLs are being referenced from the Installation Folder of the Vault application so it should work just fine. I have also checked if they are actually there (just in case) and yes they exist.
What I have tried to fix this:
Removing the references and adding them again
Compiling the project with x86 architecture
Cleaning and rebuilding the application
Unfortunately the Referencing still only works if I set the Copylocal attribute to true, otherwise it throws me the IO Exception. The Error occurs on runtime of the program.
Is there any way to fix this or am I doing something wrong?

WiX installer project: CefSharp.Core.dll could not be loaded, file not found

I am working on a windows application on c# visual studio, i have set up a WiX project for the installer and have added CefSharp, CefSharp.Core, CefSharp.Wpf references to it also.
However, upon building, it throws an error that the extension
'..\packages\CefSharp.Common.57.0.0\CefSharp\x86\CefSharp.Core.dll' could not be loaded because of the following reason: Could not load
file or assembly 'CefSharp.Core.dll' or one of its dependencies. The
specified module could not be found. InstallProj candle.exe 0
The file exists in that directory but for some reason it cannot be loaded. I have tried referencing both x64 and x86 but to no avail. But when I unload the WiX project and build, the error does not occur build successfully.
I have browsed a lot of similar questions where this dll could not be loaded but none helped fix my issue. I have tried reloading the dependencies
Edit:
I tried removing the references and uninstalling the CefSharp.Common and CefSharp.Wpf packages from InstallProj. It still tries to load the dll with the same error.
As written in the comments, I downgraded from WiX toolset v4.0 to v3.11 and fixed it in this case

VS 2010: C# Project Cannot Open DLL

I'm having an issue building a project that references a DLL located in the project's bin folder, which up until yesterday was building and running without issue.
The error I'm getting is fatal error CS0009: Metadata file 'c:\MyProject\bin\myClient.dll' could not be opened -- 'Error importing module 'myClient.netmodule' of assembly 'c:\MyProject\bin\myClient.dll' -- The system cannot find the file specified.' Intellisense is similarly complaining that The type or namespace 'Api' does not exist in the namespace 'Client' since it can't find the DLL.
Let me know if you think this is a duplicate, but I've viewed several similar posts and the solutions did solve my problem. Here are some examples:
Visual Studio 2010 — are you missing a using directive or an assembly reference?
VS2010 - Getting “type or namespace name could not be found” but everything seems ok?
Stymied by ASP.NET Compilation Error CS0009
Metadata file '…\Release\project.dll' could not be found in Visual Studio
Visual Studio 2010: Metadata file “…/Debug/Graph.dll” could not be found
Metadata file … could not be found error when building projects
Specifically, I've tried the following solutions (and combinations of these):
Cleaned and rebuilt my project.
Made sure that the target framework is not a 'client profile' version of .NET
Verifyied that the dll has been added as a project reference
Removed and re-added the project reference
Verified that the project is showing the DLL in the References section in Visual Studio
Repaired .NET
Verified the location of the DLL (it is in the local project's bin folder as given by the error)
Tried other versions of .NET
Closed and restarted Visual Studio
Rebooted my machine
Verified there are no hidden characters surrounding the 'using' statement
Removed all code changes since the last working build
Verified the settings in Configuration manager, including that 'Build' is checked
The project calling the DLL is a small class library that resides in a solution with one other small project (a console application). The DLL is an external DLL that I've been using successfully for several weeks in this project/solution. The error arises regardless of whether I build the project from the solution or by itself.
Any ideas about what could be going on?
Have you included bin folder in your project accidentally? If yes that might cause the issue. You can't include bin folder in your project as the bin folder will be created by the VS. If you accidentally include bin folder in your project, the bin project will be set to Copy to output which when you compile, the file is deleted and copied to output by Visual Studio that trigger weird behavior that some file is missing.
Hopes this help
Well I'm not sure exactly what happened here, but here is what finally resolved the issue:
A good-old-fashioned delete every single file and rebuild the project from those files from scratch. I gave +1 to some of the responses because they were useful to consider, and because there was probably a messed-up reference some where as Jonathon Wood suggested.

VS2012 dll file not found at run time

I have a project that references a dll file. I simply added a reference by right clicking on the properties, selected add reference, and browsed for the dll. Intellisense recognizes the library and all it's classes/methods but when I run it I get this.
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in program.exe
Additional information: Could not load file or assembly 'Api.dll' or one of its dependencies. The specified module could not be found.
The file appears in the bin folder and is still at the location I browsed too. The program runs without errors if I don't use any classes or methods. The library doesn't have any dependencies I'm aware of.
Edit: found a lot of missing dependent DLL files using dependency walker that I thought were causing the problem. After putting all the dependent DLL's in the same folder and referencing it the problem persists
Run Fusion Log Viewer when you run your app. It will tell you exactly what assembly isn't loading.
If nothing shows up in Fusion Log Viewer when you run it, try these settings:
I never did understand why results wouldn't show up unless I used the settings this way. I would delete all entries, run the app, then hit the Refresh button.
Turns out that even once I found the missing DLL's using dependency walker that they weren't being imported into my project with the original DLL. Moving them into the bin/debug folder fixed the error

c# app can't find dll in its working directory

I just switched from C++ to C# and I am a bit confused about referencing DLLs.
I have a third party DLL and a simple testing application that uses some of its methods. When I compile the project, everything goes well, but when I run the compiled app on another computer, I've got an error that says that the DLL is missing even though the DLL is in the app's working directory. What's even more strange is that I have access to the source code of another app that is dependent on an older version of this DLL and this app works well.
I've gone through the code and all the solution settings without finding anything really different.
Can you tell me how to reference a .dll from a working dir (Visual Studio 2010)?
Below is the exception:
System.IO.FileNotFoundException was unhandled
Message=Could not load file or assembly 'TIS.Imaging.ICImagingControl32, Version=3.2.4.1146, Culture=neutral, PublicKeyToken=257805929e8b7928' or one of its dependencies. The system cannot find the file specified.
Source=ICtestapp
FileName=TIS.Imaging.ICImagingControl32, Version=3.2.4.1146, Culture=neutral, PublicKeyToken=257805929e8b7928
FusionLog=WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
StackTrace:
at ICtestapp.Form1.InitializeComponent()
at ICtestapp.Form1..ctor()
at ICtestapp.Program.Main()
InnerException:
Here's a good blog post from Suzanne Cook from the .net team on debugging .net loader issues.
http://blogs.msdn.com/b/suzcook/archive/2003/05/29/57120.aspx
and here's the details on how it loads:
http://msdn.microsoft.com/en-us/library/yx7xezcf(v=vs.71).aspx
You have to add the dll as reference in your project references, once you added the library in the reference, when you compile the program the dll will be automatically copied to the compilation output folder unless otherwise specified in the reference properties ...
Then if you copy all items that you will find in the compilation output folder in the new location in the other PC, you should not have any problems.
Check also that the .NET framework installed on the other machine is at least as the same level of the project target ..
This also happens when you copy the debug executables over to another machine. Try compiling in release and moving over.

Categories

Resources