Deploying Oracle clients in. NET Setup

Source: Internet
Author: User
Tags file system flush
Oracle| Program | introduction | Clients are mainly to do three pieces of work: packaging files, write the registry, register environment variables
Description: My Oracle version is 9, test pass on Advanced Server, you can create a database connection normally


1. Packaging files
The catalog results are shown in the following figure




The following is a list of files 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 under 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 value of the HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0 found on the Internet is not necessary.

3. Registration environment variable
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment
 "path" + + "D:\oracle\ora90\bin;"

The best thing to note here is that you don't have to set the path directly into this value, this will overwrite the original path of the system, so it is best to add it on the original path. However, you cannot do this by setting the registry directly in the. NET Setup program, which can be done in your program by adding a custom installation action.

One problem is that the path does not take effect immediately after setup, so after installing the program, the system cannot find the Oracle Bin directory and cannot establish a database connection. My approach now is to copy all 29 files in the Bin directory to the system's [Systems directory] (in the. NET deployment program, the file system-> special folders). It's kind of vicious, but live for a while:) Whoever finds a solution, 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 Entries </param>
<param name= "Registrykeys" > Registry entry array, representing the path of the specified value </param>
<param name= the name of "VALUENAME" > Value </param>
<param name= "value" > Values to write </param>
<param name= "Append" > whether to add before the current value, if no, overwrite current value </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




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.