How to set proper path to TNSNAMES file in C# application?

后端 未结 3 737
忘掉有多难
忘掉有多难 2021-01-06 01:52

I have a program in C# that use ODP.NET dlls:

oci.dll, ociw32.dll, Oracle.DataAccess.dll,
orannzsbb11.dll, oraocci11.dll, oraociicus11.dll,
OraOps11w.dll. 
<         


        
3条回答
  •  自闭症患者
    2021-01-06 02:17

    You don't need to care about the path of your TNSNames file: it'll be automatically discovered by the library itself... once you have it installed. That's the key point: distributing the dll within your project is not enough. You need to install ODP.Net on the machine that need to use it: actually the installation simply create a few registry entry, and one of them point to the right oracle dir (in which the library can find out the tnsnames when needed).

    Morover, as someone pointed out, you don't need a tnsnams file at all. You could write everything needed inside the connection string. Here's one I use in my environment:

    Data Source= (DESCRIPTION =
          (ENABLE = BROKEN)
          (ADDRESS_LIST =
          (LOAD_BALANCE = ON)
          (FAILOVER = ON)
          (ADDRESS = (PROTOCOL = TCP)(Host =por10srv-a)(Port = 1521))
          )
          (CONNECT_DATA =
          (SERVICE_NAME = por10.gruppo.autostrade.it)
          (FAILOVER_MODE =
          (TYPE = SELECT)
          (METHOD = BASIC)
          (RETRIES = 10)
          (DELAY = 3)
          )
          )
          );User ID=npa_collaudo;Password=npa_collaudo;
    

提交回复
热议问题