The main task is to package files, write the registry, and register environment variables.
Note: My oracle version is 9 and has passed the test on the 2000 advanced server. You can create a database connection normally.
1. Package files
Shows the directory result.
The following is the file directory in my package,
Bin: the most important thing is the bin directory. In my package, 29 files are required:
--------------------
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 content of the tnsnames. ora file is as follows: (SERVICE_NAME = server connection)
Orcl =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = 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 Registry
HKEY_LOCAL_MACHINE/software/Oracle
"ORACLE_HOME" = "C:/Oracle/ora90"
I found that the oracle_home value under hkey_local_machine/software/oracle/home0 found on the Internet is not required.
3. Register Environment Variables
Hkey_local_machine/system/controlset001/control/session manager/environment
"Path" + = "d:/oracle/ora90/bin ;"
Note that you do not need to set the path directly to this value. This will overwrite the original path of the system, so it is best to add it on the original path. however. in the. net installer, you cannot directly set the Registry. In this case, you can add a custom installation operation to complete the installation.
One problem is that it does not take effect immediately after the path is set. Therefore, after the program is installed, the system cannot find the bin directory of oracle and cannot establish a database connection. my current practice is to copy all 29 files under the bin directory to the [system Directory] (In.. net deployment Program, file system-> special folder ). it's a bit vicious, but let's get together for a while. Who can find a solution? Please 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 );
}
///
/// Write the specified value to the Registry
///
/// <Param name = "startkey"> initial registry key </param>
/// <Param name = "registrykeys"> registry entry array, indicating the path of the specified value </param>
/// <Param name = "valuename"> name of the value </param>
/// <Param name = "value"> value to be written </param>
/// <Param name = "APPEND"> whether to add the value before the current value. If not, the current value is overwritten. </param>
Private void setregistrykey (registrykey startkey, string [] registrykeys, string valuename, string value, bool append ){
Registrykey 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 );
}
}
} 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