Problems with OraDirect and DbProviderFactories.GetFactory
Problems with OraDirect and DbProviderFactories.GetFactory
Can someone provide a complete example demonstrating how to code a generic, factory-based implementation using OraDirect 3.5.9?
I have added the following to the machine.config under :
This causes the OraDirect provider to show up in the DataTable returned by DbProviderFactories.GetFactoryClasses(). However, when it comes to creating a DbProviderFactory using DbProviderFactories.GetFactory("Corelab.Oracle") the system throws an ArgumentException with the message "Unable to find the requested .Net Framework Data Provider. It may not be installed."
Any help would be greatly appreciated. Thanks in advance!
I have added the following to the machine.config under :
This causes the OraDirect provider to show up in the DataTable returned by DbProviderFactories.GetFactoryClasses(). However, when it comes to creating a DbProviderFactory using DbProviderFactories.GetFactory("Corelab.Oracle") the system throws an ArgumentException with the message "Unable to find the requested .Net Framework Data Provider. It may not be installed."
Any help would be greatly appreciated. Thanks in advance!
Correcting InvariantName did not solve the problem. However, during troubleshooting I discovered the license file was not included in the assembly. This corrected the issue on the development machine. Unfortunately, I am now having a different problem with the deployed solution.
The entire contents of the \bin\debug folder including the CoreLab.Oracle.dll file was copied to a non-development machine. As on the development machine, the OraDirect generic provider was defined in the DbProviderFactories section of the application's .exe.config file. No license files were deployed.
When the deployed application attempted to create a DbProviderFactory an exception with the message "The requested .Net Framework Data Provider's implementation does not have an Instance field of a System.Data.Common.DbProviderFactory derived type." was thrown. The CoreLab.Oracle.dll file was then added to the machine's GAC with the same result.
Any thoughts?
The entire contents of the \bin\debug folder including the CoreLab.Oracle.dll file was copied to a non-development machine. As on the development machine, the OraDirect generic provider was defined in the DbProviderFactories section of the application's .exe.config file. No license files were deployed.
When the deployed application attempted to create a DbProviderFactory an exception with the message "The requested .Net Framework Data Provider's implementation does not have an Instance field of a System.Data.Common.DbProviderFactory derived type." was thrown. The CoreLab.Oracle.dll file was then added to the machine's GAC with the same result.
Any thoughts?
Referencing my previous post, "As on the development machine, the OraDirect generic provider was defined in the DbProviderFactories section of the application's .exe.config file." We prefer not to deploy to the machine.config, using the application config file instead. This works fine on the development machine. I will do some further testing with this in mind but really don't think that's the problem. Can you suggest anything else I might check?
The project files can be downloaded from here:
http://www.flnet.net/files/orasimple.zip
This version uses OraDirect 3.50.9 but 3.50.11 produces the same result. The call to DbProviderFactories.GetFactory throws an exception with this text: "The requested .Net Framework Data Provider's implementation does not have an Instance field of a System.Data.Common.DbProviderFactory derived type." Using the OraDirect objects directly does not produce the error.
I have tried this with the CoreLab.Oracle.dll file in the application folder and in the GAC. The results are always the same. The application works when run on a machine where the OraDirect setup was run and fails on all others.
This should be fairly simple to recreate. Just install the .NET Framework 2.0 on a machine on which the OraDirect setup has NOT been run. Then, expand the zip file, compile the application and copy the \bin\debug folder to the test machine.
http://www.flnet.net/files/orasimple.zip
This version uses OraDirect 3.50.9 but 3.50.11 produces the same result. The call to DbProviderFactories.GetFactory throws an exception with this text: "The requested .Net Framework Data Provider's implementation does not have an Instance field of a System.Data.Common.DbProviderFactory derived type." Using the OraDirect objects directly does not produce the error.
I have tried this with the CoreLab.Oracle.dll file in the application folder and in the GAC. The results are always the same. The application works when run on a machine where the OraDirect setup was run and fails on all others.
This should be fairly simple to recreate. Just install the .NET Framework 2.0 on a machine on which the OraDirect setup has NOT been run. Then, expand the zip file, compile the application and copy the \bin\debug folder to the test machine.
Was OraDirect installed on your test machine using the installer? If so, it will work every time. What we are attempting to do is xcopy deploy the CoreLab.Oracle.dll file into the application folder without running the installer. This works fine when not using the generic data objects but fails using the factory approach.
Yes, it works without installing OraDirect .NET. You have to add the following to (Windows folder)\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config
The correct path to this tag in machine.config is
and add CoreLab.Oracle.dll to GAC. Please note that "type" parameter is different from your post, we recommend to use it with OraDirect .NET, but your example works with your registration information.
The correct path to this tag in machine.config is
The following text was inserted into the prescribed position in the test machine's machine.config file. Other than the version number in the description, the text is exactly like that inserted into the development machine's machine.config file when OraDirect 3.5.0.11 was installed.
In addition, the development machine ran the same test code successfully after removing the reference to OraDirect in the machine.config. This seems to indicate that the presence or absence of the OraDirect definition in machine.config or app.config has nothing to do with the problem. This makes sense, since the code in the sample should rely entirely upon reflection to find the required assembly.
There must be something else in the install process that affects the usage of generic data access factories. Can someone check with the folks that created the installer? Perhaps they can shed some light on what takes place during a standard install that might affect this.
Following the machine.config modification the test computer was rebooted and the application was run again. The results were exactly the same. The call to DbProviderFactories.GetFactory throws an exception with this text: "The requested .Net Framework Data Provider's implementation does not have an Instance field of a System.Data.Common.DbProviderFactory derived type." As before, a direct connection using OraDirect without the generic factory implementation worked fine. The test was repeated again after adding all the strongly named CoreLab dlls from the application folder to the GAC and rebooting (just in case). Again, the result was the same.
In addition, the development machine ran the same test code successfully after removing the reference to OraDirect in the machine.config. This seems to indicate that the presence or absence of the OraDirect definition in machine.config or app.config has nothing to do with the problem. This makes sense, since the code in the sample should rely entirely upon reflection to find the required assembly.
There must be something else in the install process that affects the usage of generic data access factories. Can someone check with the folks that created the installer? Perhaps they can shed some light on what takes place during a standard install that might affect this.