Deploying Oracle clients in the NET Setup program
The main thing is to do three pieces of work: packaging files, writing the registry, registering environment variables
Description: My Oracle version is 9, test passed on the Advanced Server, the database connection can be created normally
1. Packaging files
The catalog results are as shown
Here is the file directory in my packaging program,
bin : The most important of course is the bin directory, in my packaging program, requires 29 files:
  |
-------------------- Oci.dll Oraclient9.dll Oracommon9.dll ORACORE9. DLL Orageneric9.dll Oraldapclnt9.dll Oran9.dll ORANCDS9. DLL Orancrypt9.dll Oranhost9.dll Oranl9.dll Oranldap9.dll ORANLS9. DLL Oranms.dll Oranmsp.dll Orannts9.dll Orannzsbb9.dll Oranoname9.dll Oranro9.dll Orantcp9.dll Orantns9.dll ORAPLS9. DLL ORASLAX9. DLL ORASNLS9. DLL ORASQL9. DLL Oratrace9.dll ORAUNLS9. DLL Oravsn9.dll Orawtc9.dll -------------------- |
network/admin : Tnsnames.ora
The contents of the Tnsnames.ora file are as follows: (service_name = Server connection)
ORCL =
(DESCRIPTION =
(Address_list =
(ADDRESS = (PROTOCOL = TCP) (HOST = xxx.xxx.xxx.xxx) (PORT = 1521))
)
(Connect_data =
(service_name = ORCL)
)
)
ocommon/nls/admin/data: All files in the original Oracle installation directory
oracore/zoneinfo : Timezone.dat
2. Write the Registration form
Hkey_local_machine/software/oracle
"Oracle_home" = "C:/oracle/ora90"
I find that the Oracle_home values found on the Internet are not necessarily HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/HOME0.
3. Registering Environment variables
Hkey_local_machine/system/controlset001/control/session manager/environment
"path" + = "D:/oracle/ora90/bin;"
It is important to note that it is best not to set the path directly to this value, which will overwrite the original path of the system, so it is best to add on the original path. However, in. NET setup, you cannot do this by directly setting up the registry, which can be done in the program by adding a custom installation action.
One problem is that it does not take effect immediately after the path is set, so after the program is installed, the system cannot find the Oracle Bin directory and cannot establish a database connection. What I do now is to copy the 29 files in the Bin directory to the system directory (in. NET's deployment program, file system-special folders). A little vicious, but just live it:) Who found a way to fix it, remember to tell me.
The sample code is as follows:
#region Check Oracle client Settings///// Check Oracle Client settings //private void Checkoracleclient () {string[] keys = {"SYSTEM", "ControlSet001", "Control", "Session Manager", " Environment "}; This. Setregistrykey (Registry.localmachine, Keys, "Path", @ "C:/oracle/ora90/bin", true); Keys = new string[] {"Software", "ORACLE"}; This. Setregistrykey (Registry.localmachine, Keys, "Oracle_home", @ "C:/oracle/ora90", false); } ////// writes the specified value to the registry /// <param name= "Startkey" > Initial registry key </param>///<param Name= "Registrykeys" > registry key array, representing the path of the specified value Diameter </param>//<param name= "ValueName" > Value name </param>//<param name= "value" > Value to write < /param>//<param name= "append" > whether to add before current value, if no, overwrite current value </param> private void Setregistrykey (Reg Istrykey Startkey, string[] Registrykeys, String valueName, String value, bool append) {Registryke Y rk = Startkey; RegistryKey subkey = NULL; for (int i=0; i<registrykeys.getlength (0); i++) {subkey = RK. OpenSubKey (Registrykeys[i], true); if (subkey = = NULL) {subkey = RK. CreateSubKey (Registrykeys[i]); } RK = subkey; } if (append) {if (RK. GetValue (valueName) = = null) {RK. SetValue (valueName, value); } else { String oldValue = rk. GetValue (ValueName). ToString (); if (Oldvalue.indexof (value) > 0) {rk. SetValue (ValueName, Value + ";" + OldValue); }}} and else {if (RK. GetValue (valueName) = = null) {RK. SetValue (valueName, value); Rk. Flush (); }} if (subkey! = null) {subkey.close (); } rk. Flush (); Rk. Close (); } #endregion Check Oracle client settings
This article by the Bean John Blog backup expert remote One click release
Deploying Oracle clients in the NET Setup program