I have a small command line app that uses the Oracle client (specifically, Oracle.DataAccess). I have version 2.11.7.20 installed on my development machine but the server the app will eventually run on has version 2.11.7.0. When I try to run the app on the server, it fails stating it can't find the dll or one of its dependencies (the located assembly's manifest definition does not match the assembly reference).
I copied the Oracle.DataAccess.dll from the server onto my machine, changed the project to reference it instead, and recompiled. It now runs properly on the server.
But, there must be a cleaner way of handling version problems like this, especially something as minor as x.x.x.0 to x.x.x.20. I have been developing in ASP.NET for years, where you can just alter the references to the assembly in web.config to sort out issues like this, but this is my first "desktop" application and have no idea what to do. I tried setting "Specific Version" to false under the properties in Visual Studio for the refe开发者_JS百科renced assembly but it didn't seem to do anything. I also tried adding an assemblyBinding to the app.config file but that caused the app to crash immediately.
<runtime>
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="Oracle.DataAccess"
publicKeyToken="89b483f429c47342" />
<bindingRedirect oldVersion="2.111.7.20"
newVersion="2.111.7.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
EDIT: D'oh, I put the runtime section as the first block in app.config instead of after configSections. The app no longer crashes, but I still get the same error.
The desktop equivalent of web.config is App.config (which will be automatically copied to your output folder and renamed to .config). So you can put it in App.config in your project if it helps (you might need to add this file to your project first).
Oracle client is a big pain!
Have you looked at alternate Oracle providers like devArt's dotConnect? This driver, as an example, is 100% managed code, supports many advanced Oracle features, provides Entity Framework support (that will come some day in ODP.NET, I'm sure).
D'oh again. I left the xmlns off of the assemblyBinding; when I put it on, everything worked perfectly. So...you can use bindingRedirect to go backwards version-wise.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Oracle.DataAccess"
publicKeyToken="89b483f429c47342" culture="neutral" />
<bindingRedirect oldVersion="2.111.7.20"
newVersion="2.111.7.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
精彩评论