Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw

572474Apr 29 2008 — edited Apr 30 2008
The code:

private Boolean getDBConnection()
{
//try
//{
//Connection Information
string connectionString =

//username
"User Id=" + ConnectionParams.Username +

//password
";Password=" + ConnectionParams.Password +

//replace with your datasource value (TNSnames)
";Data Source=" + ConnectionParams.Datasource;


//Connection to datasource, using connection parameters given above
conn = new OracleConnection(connectionString);


//Open database connection
conn.Open();
return true;
{

when run to conn.Open() the error:

---------------------------------------------------------------------------------------------

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..ctor(String connectionString)
at MBSOra.Form1.getDBConnection() in F:\temp\MBS\MBSOra\MBSOra\Form1.cs:line 105
at MBSOra.Form1.btnConnect_Click(Object sender, EventArgs e) in F:\temp\MBS\MBSOra\MBSOra\Form1.cs:line 37
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.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.OnMessage(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 System.Windows.Forms.Application.Run(Form mainForm)
at MBSOra.Program.Main() in F:\temp\MBS\MBSOra\MBSOra\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: Oracle.DataAccess.Client.OracleException
Message="The provider is not compatible with the version of Oracle client"
Source="Oracle Data Provider for .NET"
ErrorCode=-2147467259
DataSource=""
Number=-1011
Procedure=""
StackTrace:
at Oracle.DataAccess.Client.OracleInit.Initialize()
at Oracle.DataAccess.Client.OracleConnection..cctor()
InnerException:

-----------------------------------------------------------------------------------------

This happen when I am using Windows Server 2008 32 bit Standard edition.

When I run the same code in Win XP to access to the same Oracle 11g Database server I have no error at all.

Any help?

Ming Man
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 28 2008
Added on Apr 29 2008
2 comments
6,231 views