Deploy Oracle client all Raiders in .NET installer

xiaoxiao2021-03-06  64

The main thing is to do three work: package file, write a registry, registration environment variable description: My Oracle version is 9, testing on 2000 Advanced Server, you can create a database connection normally

1. The result of the package file directory is shown below

The following is the file directory in my package program, bin: The most important thing is of course bin directory, in my package program, you need 29 files:

-------------------- oci.dlloraclient9.dlloracommon9.dllORACORE9.DLLorageneric9.dlloraldapclnt9.dlloran9.dllORANCDS9.DLLorancrypt9.dlloranhost9.dlloranl9.dlloranldap9.dllORANLS9.DLLoranms.dlloranmsp. dllorannts9.dllorannzsbb9.dlloranoname9.dlloranro9.dllorantcp9.dllorantns9.dllORAPLS9.DLLORASLAX9.DLLORASNLS9.DLLORASQL9.DLLoratrace9.dllORAUNLS9.DLLoravsn9.dllorawtc9.dll --------------------

Network / admin: tnsnames.ora tnsnames.ora file content is as follows: (Service_name = server connection) Orcl = (description = (address = (address = (protocol = tcp) (host = xxx.xxx.xxx.xxx) (port) = 1521)))))))))))))) (service_name = orcl)))))

Ocommon / NLS / Admin / Data: Original Oracle installation directory All files ORACORE / ZONEINFO: Timezone.dat2. Write Registry HKEY_LOCAL_MACHINE / SOFTWARE / ORACLE   "Oracle_Home" = "c: / oracle / ora90" I found out online The oracle_home value under the HKEY_LOCAL_MACHINE / SOFTWARE / ORACLE / HOME0 is not required.

3. Register Environment Variable HKEY_LOCAL_MACHINE / System / Controlset001 / Control / Session Manager / Environment  "Path" = "D: / Oracle / ORA90 / BIN;"

It should be noted here that it is best to set the PATH directly into this value, so that the original PATH is removed, so it is best to add it on the original PATH. But the .NET installer cannot be done At this time, it can be done in the program at this time.

One problem is that after setting the PATH, it will not take effect immediately. After installing the program, the system can't find the Oracle's bin directory, and it is impossible to establish a database connection. My current practice is to copy 29 files under the bin directory to the system. [System Directory] (in the .NET deployment program, the file system -> special folder). A little vicious A, but it is temporary to work :) Who finds the solution to tell me

The sample code is as follows:

#Region Check Oracle Client Settings

///

// / Check the Oracle client settings

///

Private void checkoracleClient () {

String [] Keys = {"System", "Controlset001", "Control", "Session Manager", "Environment"}; this.setRegistryKey (Registry, @ ", keys," path ", @" c: / oracle / ora90 / bin ", True);

Keys = new string [] {"Software", "Oracle"}

THIS.SETREGISTRYKEY (Registry, "Oracle_Home", @ "c: / oracle / ORA90", FALSE);

}

///

/// Write the specified value to the registry

///

/// Initial registry key

/// Registration form item array, indicating the path of the specified value

/// Name of the value

/// Value to write

/// Does it add before the current value, if not, override the current value

Private void setRegistryKey (RegistryKey Startkey, String "RegistryKeys, String Valuename, String Value, Bool append) {

RegistryKey rk = startKey;

RegistryKey Subkey = NULL;

For (int i = 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

转载请注明原文地址:https://www.9cbs.com/read-86539.html

New Post(0)