4 Replies Latest reply: Sep 9, 2010 9:27 AM by 787956 RSS

    Problems with RelationalDataSample exceptions thrown from VS2005

    655502
      I am not sure which version of the Oracle.DataAccess .Net assy to use. But both of them throw an exception at run time.

      With version 10.2.0.100 I get the following run time error.
      This is the file location of this version - C:\XEClient\bin\Oracle.DataAccess.dll
      As you can see this is the XE client version.

      Error occurred: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.

      System.TypeInitializationException was unhandled
      Message="The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception."
      Source="Oracle.DataAccess"
      TypeName="Oracle.DataAccess.Client.OracleConnection"
      StackTrace:
      at Oracle.DataAccess.Client.OracleConnection.Dispose(Boolean disposing)
      at System.ComponentModel.Component.Finalize()

      With version 2.111.6.20 I get the following run time error.
      This is the file location of this version - C:\app\john\product\11.1.0\client_1\ODP.NET\bin\2.x\Oracle.DataAccess.dll
      As you can see this is the 11g install.

      System.BadImageFormatException was unhandled
      Message="Could not load file or assembly 'Oracle.DataAccess, Version=2.111.6.20, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format."
      Source="RelationalDataSample"
      FileName="Oracle.DataAccess, Version=2.111.6.20, Culture=neutral, PublicKeyToken=89b483f429c47342"
      FusionLog="=== Pre-bind state information ===\r\nLOG: User = PureVirtual-1\\john\r\nLOG: DisplayName = Oracle.DataAccess, Version=2.111.6.20, Culture=neutral, PublicKeyToken=89b483f429c47342\n (Fully-specified)\r\nLOG: Appbase = file:///C:/Users/john/Documents/Visual Studio 2005/Projects/RelationalDataSample/RelationalDataSample/bin/Debug/\r\nLOG: Initial PrivatePath = NULL\r\nCalling assembly : RelationalDataSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: No application configuration file found.\r\nLOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\\config\\machine.config.\r\nLOG: Post-policy reference: Oracle.DataAccess, Version=2.111.6.20, Culture=neutral, PublicKeyToken=89b483f429c47342\r\nLOG: Attempting download of new URL file:///C:/Users/john/Documents/Visual Studio 2005/Projects/RelationalDataSample/RelationalDataSample/bin/Debug/Oracle.DataAccess.DLL.\r\nERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.\r\n"
      StackTrace:
      at RelationalDataSample.ConnectionMgr.getDBConnection(String username, String password, String connectString)
      at RelationalDataSample.EmpForm.btnConnect_Click(Object sender, EventArgs e) in C:\Users\john\Documents\Visual Studio 2005\Projects\RelationalDataSample\RelationalDataSample\EmpForm.cs:line 528
      at System.Windows.Forms.Control.OnClick(EventArgs e)
      at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
      at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
      at System.Windows.Forms.Control.WndProc(Message& m)
      at System.Windows.Forms.ButtonBase.WndProc(Message& m)
      at System.Windows.Forms.Button.WndProc(Message& m)
      at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
      at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
      at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
      at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
      at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
      at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
      at RelationalDataSample.EmpForm.Main() in C:\Users\john\Documents\Visual Studio 2005\Projects\RelationalDataSample\RelationalDataSample\EmpForm.cs:line 509
      at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
      at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
      at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
      at System.Threading.ThreadHelper.ThreadStart()

      Any help with this is greatly appreciated.

      Thank you,
      John
        • 1. Re: Problems with RelationalDataSample exceptions thrown from VS2005
          24208
          Hi John,

          Are you still chasing this issue down?

          I have found that one of the causes of the "System.BadImageFormatException" exception results from the following set of circumstances:

          o 32-bit ODP.NET installed on 64-bit o/s
          o .NET application compiled with either "Any CPU" or "x64" set for the "Platform target"
          o The application is then deployed to the 64-bit host with the 32-bit ODP.NET installed
          o The application executes as a 64-bit application but tries to load the 32-bit ODP.NET, thus the exception

          Not sure if this might apply to your situation, but I see "C:\\Windows\\Microsoft.NET\\Framework64" in the text you provided. Since there is not yet a 64-bit release of ODP.NET 11g I wonder if this might be the case.

          For what it's worth, I have not experienced any of the problems you've described in your other threads, but I am using 10.2.0.4 on Intel 64-bit with Win 2003...

          - Mark
          • 2. Re: Problems with RelationalDataSample exceptions thrown from VS2005
            657624
            I ran into the same error message using ODP.NET 11g on Vista Service Pack 1 x64 with Visual Studio 2008 Service Pack 1.

            The solution was to go to the Configuration Manager of Visual Studio and change it from Any CPU to x86. The application ran just fine after that.

            John Cook
            author of Build a .NET Application on the Oracle Database
            http://www.oracle.com/technology/pub/articles/cook_dotnet.html
            • 3. Re: Problems with RelationalDataSample exceptions thrown from VS2005
              690082
              Hi there. I'm having a similar problem to that reported by user652499 with an application I migrated to the 3.5 version of .Net Framework. This is a set of asp.net forms that use a propose-built library to connect to Oracle. On the development environment it goes ok, but in the testing environment I'm getting this error:

              Could not load file or assembly 'Oracle.DataAccess, Version=1.102.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.

              The development environment is:
              Windows Vista Business
              IIS 7.0
              Visual Studio 9
              Oracle Client 10.2.0

              The testing environment is:
              Windows Server 2003
              IIS 6.0
              Oracle Client 10.2.0

              Since both are x86 boxes I toggled the Configuration Manager accordingly, as suggested by Mark Williams, but to no avail.

              Thanks for any help.
              • 4. Re: Problems with RelationalDataSample exceptions thrown from VS2005
                787956
                One solution is: in IIS go to whatever the app pool that running your website, click on "Advanced Settings", the set "Enable 32-Bit Applications" to True. This should solve the problem.

                Gabe