'System.IO.FileNotFoundException: 'Could not load file or assembly
I am beginner in C# and trying to add one DLL in project but getting the below error when running the project :
System.IO.FileNotFoundException: 'Could not load file or assembly 'Interop.TrueConf_CallXLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.'
I have tried to run it on Any CPU, X64 and x86 but its almost the same error. Can you please help me fix it ?
Below is the full exception :
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Interop.TrueConf_CallXLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
at AxTrueConf_CallXLib.AxTrueConfCallX.AttachInterfaces()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
at System.Windows.Forms.AxHost.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The program '[20208] TruconfCall.exe' has exited with code 0 (0x0).
Solution 1:[1]
The error says
System.IO.FileNotFoundException: 'Could not load file or assembly 'Interop.TrueConf_CallXLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.'
So I suspect there must be some more dlls on which current dll is depends. So instead of adding dll using browse option, first install TrueConf SDK and reference it from assembly if SDK install libraries to GAC.
Solution 2:[2]
Any CPU
You just opened a huge can of worms, because Any CPU is a .Net concept, it doesn't map to more native processes, and indeed the CPU itself doesn't support it. And since COM uses native libraries to work, you really have to pick one architecture on both client and server, and stick with it.
Now that out of the way, you say that the dll exists on disk, but it won't load with the exception above, so short of you doing anything wonky like deleting the file from the output binary folder, or doing something to prevent the file from being copied, the biggest problem I can think of is that you're missing one of the libraries' dependencies, perhaps the correct C++ runtime (both version and architecture!) ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Chaturvedi Dewashish |
Solution 2 | Blindy |