System.IO.FileNotFoundException: Could not load file or assembly C# - c#

I was created one cpp GOQii_API.dll with clr support and which uses the another dll (dongle.dll).and this GOQii_API.dll used in my C# code.
the above structure is working very well in both system 32bit and 64 bit where visual studio 2010 is installed.
but, When i created mis setup and installed on fresh machine where development environment is not present. Then it gives me following error.
System.IO.FileNotFoundException: Could not load file or assembly 'GOQii_API.dll' or one of its dependencies. The specified module could not be found.
File name: GOQii_API.dll

Thank u friends.
I got the solution by using the "Process walker tool" i missed to copy "msvcr100d.dll" with my source code.
use "Process walker tool" shows you what dependency .dll required and you missed.

Related

Could not load file or assembly 'Microsoft.SqlServer.Replication

I have an c# application using 'Microsoft.SqlServer.Replication .NET Programming Interface DLL.
(Microsoft.SqlServer.Rmo.dll)
I need there the TransSubscription and TransPublication.
I can build the solution without any error or warning, and run it in Debug and Release mode on my computer. But if I would like to start the release application an another computer, i receive the error:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.Replication, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.SqlServer.Replication, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
I tried it to have as x64 and x86 application, no affect. I cannot interop the DLL, there will be errors in Vistual studio.
Anyone has an idea?
Thank you
Edit:
Meanwhile i did some more testing..
I have installed on a new VM SQL server to get only the available, and in the rght version dll. Installed VS and build the project. This was sucessful, no errors. But if i am starting the app, already in debug mode it crashed with the same error code. any idea?
The dll is referenced all build is completed.
Edit:
According: https://learn.microsoft.com/en-us/sql/relational-databases/replication/concepts/replication-management-objects-concepts?view=sql-server-ver15 i need to add Replication Agent Library (REPLAGNT.dll) but this i cannot do in VS, "A reference to .... could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component". What do i do wrong?
For me it sounds like you referenced a dll which is located in a local folder, which works okay as long as you are working on your machine, but crashes as soon as you using another machine. After a build/rebuild a dll should be located in the bin folder.

How to import a Windows.UI.dll in a console application using Reflection and Visual Studio

I am using a Visual Studio 2017 Community Version to develop a console application using Reflection. I want to analyse the dll file of Windows.UI.Notifications using Reflection.
However, when I try to load the dll file using Assembly.LoadFrom("path") , the program throws an error given below.
System.BadImageFormatException: "Could not load file or assembly '(path)' or one of it's dependencies. The module was expected to contain an assembly manifest."
I am working on a Windows 10 64 bit system. I have tried loading the dll from System32 folder , SystemWOW64 and also from ProgramFiles(x86) directly. I also tried to copy the dll from these folders to a different folder. But each time the error is thrown while loading the assembly. I am able to load Xamarin dlls using the same methods.
In order to use Assembly.LoadFrom(path), dll file must be .Net assembly but in your case Windows.UI.dll is not a .Net assembly but native code. You can not use Assembly.LoadFrom(path).
If you want to use Windows.UI.dll in your .net application please refer to this page

.NET exe not picking dll dependencies

I have developed an EXE again :)
The problem is it has refernces of SQLite dll file so I included the file on the same path. Now in Windows 8 it is running fine, but in Windows 7 it is not
The error is
System.IO.FileLoadException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.90.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. (Exception from HRESULT: 0x800736B1)
File name: 'System.Data.SQLite, Version=1.0.90.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' ---> System.Runtime.InteropServices.COMException (0x800736B1): The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
I did everything I could but it is not running on Windows 7
It's a standalone EXE. No Setup.
EDIT:
This is what application event log says
Activation context generation failed for "C:\System.Data.SQLite.dll". Dependent Assembly Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195" could not be found. Please use sxstrace.exe for detailed diagnosis.
I think thats the reason as you mentioned, SQLLite is searching 64 bit dll!
Try to download 64 bit url and pack it with exe
You can download from here
http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
side-by-side configuration is incorrect
That means Either:
One of your reference DLLS do not match your project target type
Or Your reference DLLS are of mixed target types
Solution:
Make sure your Project is set to build to target x86 for x86 reference DLLs or target x64 for x64 reference DLLs, and the same for the .NET versions
Make sure all your reference DLLs are either all x86 or all x64 versions and not x86 and x64, and the same for the .NET versions
If you are not sure you can use IlSpy to check by right clicking on the reference.
Generally this error indicates that a dependent assembly is missing.
Activation context generation failed for "C:\System.Data.SQLite.dll".
Dependent Assembly
Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
could not be found. Please use sxstrace.exe for detailed diagnosis.
This assembly is more commonly known as
Microsoft Visual C++ 2005 Redistributable Package (x86)
and can be downloaded from here.
But, often there is another cause. Today, for us, it was "Bit9 Security" which did not like us digitally signing the SQLite.dll assembly on our local machine and uploading the signed assembly to our server application folder with a different time stamp to the rest of the assemblies in the application folder.
The work around was to recompile the application, sign all the assemblies, upload and overwrite the existing application files.

C# Project, GAC, DLL

i'm having a problem with my built Application.
I have a project taken from here modified it and implemented in my program.
Shortly, this TableProc project generates a report to OpenOffice Calc and uses some libraries from OpenOffice - cli_basetypes (GAC/MSIL), cli_oootypes (GAC/MSIL), cli_uno (GAC/MSIL), cli_ure (GAC/MSIL), cli_uretypes (GAC/MSIL) AND cli_cppuhelper (GAC32).
Looks like:
Solution
.....Project1 (references TableProc)
.....Project2 (references TableProc)
.....TableProc (implemented) (references on libraries in bin directory cli_basetypes.dll and others)
So, when i'm in debugging mode VS 2010, those DLL are in directory */bin/ - Everything works fine - reports are done.
But when i build up my application:
1. There are no DLL's for cli_basetypes, cli_oootypes and others
2. There are project1.dll, project2.dll and TableProc.dll and
Program.exe
PROBLEM:
In a built up application, it tells that:
Error 1:
Could not load file or assembly 'cli_cppuhelper, Version=1.0.14.0,
Culture=neutral, PublicKeyToken=ce2cb7e279207b9e' or one of its
dependencies. Ann attempt was made to load a programm with an
incorrect format.)
Ok, I tried to manually put those DLL's next to my Program.exe - same error.
Then I found out, that those libraries are installed in GAC when you install Open Office. I looked at them, and noticed that all of them are installed in GAC/MSIL but cli_cppuhelper is installed in GAC/32.
I tried to manually copy cli_cppuhelper assembly from GAC/32 to GAC/MSIL, and got this error:
Error 2:
Is not a valid Win32 application. (Exception from HRESULT:
0x800700C1))
From this i understood, that my apllication, when looks for DLL's it looks only in GAC/MSIL
Please help, i don't know what to do...
For those that find this in the future.
The problem is that the targeted platform in Visual Studio is incorrect. The .dlls need to be compiled with the correct bit version.
You need to change the targeted platform in Visual Studio to:
64-bit -> x64
32-bit -> x86
Note: AnyCPU does not work.
Change your Platform from AnyCPU to x86.

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