Reputation: 728
I created a C# project on my computer that uses ODP.net, I imported the reference of Oracle.DataAccess. On my PC, I try to do a connection to the Database and it works normally, however, if I copy the .exe file of my application in another computer, it does not work and I receive the following error:
System.IO.FileNotFoundException: 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. File name: 'Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342'
Why doesn't C# encapsulate all the files needed in the .exe? What can I do to make this program work regardless of the executing computer?
Upvotes: 1
Views: 1308
Reputation: 40736
As of request by Vito, here is my comment as an answer:
I suggest to not use the "classic" ODP.NET which has dependencies on additional installed ODP components on the system, but instead use the purely managed version of ODP.NET.
For the managed ODP.NET you have a single assembly (i.e. a DLL) that you can ship with your application (e.g. in the "bin" folder if it is an ASP.NET application) and you're done.
Just to make it complete, the connection string in my cases looks something like:
<add
name="ora"
connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyServer)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE))); User Id=MyUser; Password=MyPassword"
providerName="system.data.oracleclient" />
The managed version was really a huge improvement in terms of ease-of-use in my projects.
Upvotes: 1
Reputation: 13523
Please see the answer to a similar question I had. Mainly this problem is about oracle.dataaccess.dll
, it's build platform (32 or 64) and presence of some of it's dependencies (like OraOps11w.dll
). These things should be checked to see if are present and configured correctly. It would get big in deployment! Of-course if you are calling the library at machine level (not app level) from different applications, you should check if it's registered in GAC too.
Edit: In it's simplest form:
1 - You need to have these dlls in your app directory: OraOps11w.dll
, oci.dll
, orannzsbb11.dll
and oraociei11.dll
.
2 - You have to add a reference to Oracle.DataAccess.dll
.
Where can one get these?
1 - From the installation directory of you Oracle Client (not Server), if you already had installed the oracle client (including ODP.NET).
2 - If you have installed ODT.NET.
3 - By getting ODP.NET (preferably the zip archive, not the install package).
Upvotes: 1
Reputation: 631
There are TONS of possible causes to your problem here. I would first start by copying the entire folder than contains the .EXE file, and not just the .EXE file itself. There are things in this folder that your .EXE needs in order to run. Also, I would check the dependencies on the computer that is not working with the program Dependency Walker. Things can go wrong if you develop on a 32-bit and try to run on a 64-bit. Things can go wrong if you develop on Windows and try running on MAC. There is a lot that can change from one computer to the next, and your code must be ready for that. Dependency walker can tell you if you aren't connecting to certain dependancies (mostly .DLL's) correctly. If you go into the release folder that contains your EXE, if there exists any .DLL files in that same directory, these .DLL's are likely needed on any computer that will try and run this program.
Upvotes: 0
Reputation: 253
you must have installed version of the Oracle Database on each machine where you intend to install your application.
Another option is to go to Oracle and download just drivers. Download from Oracle, then you need to include them with your project, reference this dll.
Upvotes: 1