"Cannot find assembly" error in VS 2008 - c#

I had a web service on a 32-bit WIndows 2003 server that accessed Oracle database. It was built and converted to DLL with no issues. Then I had to port this to Windows 2012 64-bit server and I keep getting
Could Not Load File Or Assembly 'Oracle.DataAccess' Or One Of Its Dependencies.
I downloaded and installed 64 bit ODAC, but the problem remained. It was suggested to install the 32 bit version as well and I did that, so now I have two directories in C, C:\Oracle\Products\11.2.0\client_1 and client_2, one for 64-bit and one for 32-bit. GAC also contains both x86 and AMD64 versions of Oracle.DataAccess and Oracle.Web. I still get the same error.
Looking closely, I found that when I close the error window in VS 2008, there is an output window that shows
Warning: Unable to update auto-refresh reference 'oracle.dataaccess.dll'. Cannot find assembly 'C:\Windows\Microsoft.NET\assembly\GAC_32\Oracle.DataAccess\v4.0_4.112.2.0__89b483f429c47342\oracle.dataaccess.dll'.
I checked and this folder is empty but there is a newer folder C:\Windows\Microsoft.NET\assembly\GAC_32\Oracle.DataAccess\v4.0_4.112.**3**.0__89b483f429c47342 with oracle.dataaccess.dll in it.
How can I resolve this issue? I don't know how to make the reference to v4.0_4.112.3.0__89b483f429c47342 folder instead of v4.0_4.112.2.0__89b483f429c47342 folder, if this is the cause of the problem.

I had a copy of DataAccess.DLL in BIN folder. I removed it and all is well.

Related

System.Data.SQLite.dll - System.IO.FileNotFoundException

I use SQLite and works fine on the developer machine (or machine with Visual Studio).
But it does not work on PCs without VS. I "installed" the SQLite manually (32 bit version, added to the references, Copy Local: True). I get "System.IO.FileNotFoundException" System.Data.SQLite.dll exception.
The System.Data.SQLite.dll is in the output folder.
But I can not get it to work only if I install the SQLite with this: https://system.data.sqlite.org/downloads/1.0.105.2/sqlite-netFx46-setup-bundle-x86-2015-1.0.105.2.exe
Dev PC: x64 Win 10, application: x86 only
Please let me know if you need any other information.
Check which dependencies has your executable file (and, maybe, System.Data.SQLite.dll) with Dependency Walker or similar program. Then put these libraries you found into executable's folder one by one, until your executable will work.
You need to make sure the 64 bit C++ runtime DLLs are getting installed. They'll often be on the developer's system but not as often installed by your installer on the target system. Even though this is a .NET assembly, it appears to have C++ underpinnings.

ActiViz.NET.x64 (v5.8.0): Unable to load DLL 'Kitware.VTK.vtkFiltering.Unmanaged.dll'

I'm trying to use the VTK with C# to read and write VTK/VTS files. I created a basic app, and I installed the 64-bit VTK .NET wrapper package which is called ActiViz.NET.x64 (v5.8.0).
The package installed without any problems, and I could access the Kitware.VTK namespace, but as soon as I try to create a VTK object, I got an unmanaged DLL loading error.
An unhandled exception of type 'System.DllNotFoundException' occurred in Kitware.VTK.dll
Additional information: Unable to load DLL 'Kitware.VTK.vtkFiltering.Unmanaged.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I don't think that the exact code is relevant here, but I got the exception at the following line:
vtkStructuredGrid structuredGrid = vtkStructuredGrid.New();
I'm using Windows 10 x64, Visual Studio 2015, the target .NET Framework is 4.6.2 and I have ParaView 4.1 and 5.2 installed. The DLL in question is in the bin directory of the app, but I also tried to copy it to the Windows/System32 directory, the result is the same.
Is there a way to figure out what exactly the problem is with the dll loading?
If you go to the ActiViz product page you can see the following in the FAQ:
Does ActiViz 64 work with Visual Studio?
Visual Studio is a 32 bits
application, therefore 64 bits control does not work and you need the
32 bits version of ActiViz when using the designer within Visual
Studio. Usually, the 32 bits version is used to design and the 64 bits
version is used for the final compilation.
I also use VTK/ActiViz (C#) on Visual Studio, and it works fine when my program is targeting x86 platforms. However, if I target x64 platforms, the winforms control for the render window disappears, but I can still build the executable. So do this:
1) Install Activiz.NET.x86 from NuGet & target x86 platforms;
2) Create and debug your App;
3) Make a backup of the solution folder;
4) Install Activiz.NET.x64 from NuGet & target x64 platforms;
5) Don't open the designer because it will be buggy (all RenderWindowsControl disappear);
6) Build the solution (Release x64).
So, first I wanted to know where exactly is my process looking for the missing DLL. I used Sysinternals Suite and its Process Monitor.
I referenced VTK in my .NET library which I used in my self-hosted app. The self-hosted app was the start-up project, so the runtime looked for the missing DLL in the app's directory, not the library's, where it actually was.
After I copied the missing Kitware.VTK.vtkFiltering.Unmanaged.dll to that directory, Process Monitor confirmed that the DLL was read successfully, but I still got the same exception as before.
I compared the library's and the app's bin directories, and I figured that only the Kitware.mummy.Runtime.dll and Kitware.VTK.dll were copied there automatically.
I copied all the other VTK DLLs to the app's bin, and then it finally worked.
The exception's error message wasn't detailed in the first place, but I think it is more likely a problem with the ActiViz.NET package.
You should copy all dlls from Activiz Installation bin directory even you don't need to use in your code.
C:\Program Files (x86)\ActiViz.NET 5.8.0 OpenSource Edition\bin
Managed .Net DLL's is a wrapper for unmanaged VTK libraries. Mummy.dll is for this job.

DLL not found on target machine

I am having a similar problem.
I have developed a c# app that is Pinvoking a dll which is dependent on some other dlls. On dev machine it is working fine. Even when i copy the debug folder, which contains all the dlls and exe file, to a different location it works fine.
When I copy the same folder to another machine, it gives the dll not found exception.
The interesting thing is that the error message gives a path to the code file present on the dev machine. Not sure how this information is known at the target machine?
I have tried both the debug and release versions, but release version just crashes, and the debug version gives the exception message.
I have tried the dependency walker but could not figure out if there is any missing dependent dll causing the error.
I have tried to install VC++ run time redistribution package as well but it did not work.
I am using VS2013 on Win 7 64bit on dev machine. The target is Win 7 64bit.
Dlls are related to tesseract OCR and copied from here.

An attempt was made to load a program with an incorrect format. ChilkatDotNet4. Not fixed by usual methods

I'm getting the 'An attempt was made to load a program with an incorrect format' error when trying to run a program using 32 bit version of the chilkatdotnet4 dll.
I have tried this: (setting the IIS app pool to allow 32 bit programs):
I get a "An attempt was made to load a program with an incorrect format" error on a SQL Server replication project
(Installed IIS first)
And the answer further down the page by Mazhar Karimi.
This: (changing the cpu target within VS):
Change target CPU settings in Visual Studio 2010 Express
This: (placing the chilkat library into the GAC for 32 bit!):
http://www.chilkatforum.com/questions/114/64bit-could-not-load-file-or-assembly-chilkatdotnet4-or-one-of-its-dependencies-an-attempt-was-made-to-load-a-program-with-an-incorrect-format
And finally, going into the .csproj file itself in notepad and changing the Platform Target (and anything else that mentioned platform) into x86.
Edit: I have also tried going into the .dll properties and clicking 'unblock'.
After every change I have saved, built, uninstalled and reinstalled my program (c# windows service)
I am STILL getting this error!
Any ideas?
After changing your windows service to x86 this will change the build directory to
..ProjectName\bin\x86\debug
Make sure your windows service is pointing at this directory otherwise you will be running your old (any CPU) version of the service.
If you service is not pointing at this x86 directory, uninstall and reinstall the service for the new directory

Could not load file or assembly 'Oracle.DataAccess error

I am building ASP.NET application with C# and I want to connect to oracle database.
I have added reference to Oracle.DataAccess in my application on my 64bit Microsoft Window Server 2008 machine.
I also installed ODAC (Oracle Data Access Component) on my machine
and Oracle.DataAccess.dll is also present on this path
C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess
but when i'm trying to connect i encounter following error:
Could not load file or assembly 'Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
As far as I know, the Oracle.DataAccess assembly works only with 32 bits, I also have this kind of problem with 64 bits and it really does not work. My solution was remove the 64bits from GAC and install the 32 bits on GAC. I also remove any .dll file in the bin folder to my application find the assembly on GAC.
There is no problem if your machine and operational system is 64bits, the 32bits version will work fine.
UPDATE
I recommend you take a look at Official Oracle ODP.NET, Managed Driver, that is a better version than Oracle.DataAccess. This Managed Driver does not need the Oracle Client on the machine, and you just need to provide the TNS on the DataSource field of the connection string and it works fine for 32 and 64 bits.
You need to install both x64 and x86 versions of Oracle, because something (I think it was Visual Studio) uses the x86 version when debugging.
In VS2010, I changed the platform target to x64 and this error message disappear.
essentially same error
missing ODP.NET installation components as per last post from me and the other answer participant.
You check the GAC yet?
If you do not see Oracle.xxx folders,
you are not making any headway.
put the correct version and bit of Oracle.DataAccess.dll into the application /BIN folder and make local reference. It solves many problems.
To run your website, you must use IIS since visual studio's development server only runs in 32 bit mode.
In IIS application pool, set your application to run in 64 bit. (The setting is in advanced settings)
To resolve this error, I set my app pool in IIS to allow 32bit applications.
Open up IIS Manager, right click on the app pool, and select Advanced Settings --> set “Enable 32-bit Applications” to True. It's working fine for me.
I got the same exception on a c# console app. What solved it for me is to change the platform target to x86. (project properties => build )

Categories