How do I use Oracle from .NET?

前端 未结 5 937
星月不相逢
星月不相逢 2021-01-30 11:45

Unfortunately, I\'m trying to use Oracle from .NET and it\'s like going to back to 1997. Explaining things properly is a sign of weakness and the registry and environment variab

5条回答
  •  孤街浪徒
    2021-01-30 12:09

    The simplest way to explain the issue is to point out the difference between the Oracle Client and the ODAC client libraries.

    On a 64-bit machine (Windows 7+), you need to have installed the 64-bit Oracle Client. This is the client your machine will use to connect to Oracle databases that are deployed locally on your machine. For apps hosted on a web server or other terminal server, the rule is the same.

    The trick is this... as a developer, our machines must also have the .Net IDE tooling. Oracle has a crappy naming convention but essentially there are 2 pieces: ODT (tooling) and ODAC (data access). The ODP.Net data provider is a part of the ODAC libraries.

    So... back to the IDE... Visual Studio is 32-bit and therefore we must install the tooling above in 32-bit.

    While developing, debugging, etc. VS.Net is using the 32-bit client libraries and data access libraries to work with Oracle.

    As soon as you deploy this application to a machine, it uses whatever Client is loaded on the machine unless a specific platform is targeted.

    This means if you target 32 and deploy to 64, it will break... and vice versa. The best thing to do is leave it on the any platform section, and simply remember what the hell you are doing :)

    The other thing to be careful with is to ensure both your Client and ODAC packages are of the same version... you do not want to have 11g R2 client, and 11g R5 ODAC, because as soon as you deploy, crap breaks again.


    The caveat here is if you wish to "embed" the oracle client inside your application, in which case OraOps alongside several other libraries are deployed with the application - this is called Oracle's Instant Client, and is also a part of the ODAC package and included in their full blown Client package as well.


    The good news...

    Oracle is soon (2013 Q1) to release their next ODP.Net package... which will be a fully managed-code library... meaning no more separate client or ODAC package to match up, and the platform will be ignorant of 32 and 64 bit distinctions... it will function much like the old microsoft library will, only it will be built and maintained by oracle with a more robust feature set. I only wish it would arrive sooner.

提交回复
热议问题