Home All Groups Group Topic Archive Search About

The type initializer threw an exception.

Author
10 May 2006 7:19 PM
JohnZing
When i try to open an OleDb connection (access) VS throws the following
error

The type initializer for
'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception.

Tried to find on google and no sucess... please help... thanks

    Private Sub OpenConnection()
        If _connection Is Nothing Then
            _connection = New OleDb.OleDbConnection(_connStr)
            _connection.Open()
        Else
            If _connection.State = ConnectionState.Open Then
            Else
                _connection.Open()<------- ERRROR HERE
            End If
        End If
    End Sub

Author
11 May 2006 9:21 AM
Miha Markic [MVP C#]
What makes you think that if the State is not ConnectionState.Open the
connection is closed?
Besides Open there are Connecting, Executing, Fetching or Broken.
You should really test for Connection.Closed instead.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"JohnZing" <john.z***@gmail.com> wrote in message
news:1147288777.865177.16910@j33g2000cwa.googlegroups.com...
> When i try to open an OleDb connection (access) VS throws the following
> error
>
> The type initializer for
> 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception.
>
> Tried to find on google and no sucess... please help... thanks
>
>    Private Sub OpenConnection()
>        If _connection Is Nothing Then
>            _connection = New OleDb.OleDbConnection(_connStr)
>            _connection.Open()
>        Else
>            If _connection.State = ConnectionState.Open Then
>            Else
>                _connection.Open()<------- ERRROR HERE
>            End If
>        End If
>    End Sub
>
Author
11 May 2006 7:42 PM
Miha Markic [MVP C#]
Ops, I realized that Executing, Fetching and Broken are reserved for future
versions.
Anyway, why do you need to "open" an already opened connection?
Are you nesting operations?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/


Show quote
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:%23%23EOAxNdGHA.4932@TK2MSFTNGP03.phx.gbl...
> What makes you think that if the State is not ConnectionState.Open the
> connection is closed?
> Besides Open there are Connecting, Executing, Fetching or Broken.
> You should really test for Connection.Closed instead.
>
> --
> Miha Markic [MVP C#]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "JohnZing" <john.z***@gmail.com> wrote in message
> news:1147288777.865177.16910@j33g2000cwa.googlegroups.com...
>> When i try to open an OleDb connection (access) VS throws the following
>> error
>>
>> The type initializer for
>> 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception.
>>
>> Tried to find on google and no sucess... please help... thanks
>>
>>    Private Sub OpenConnection()
>>        If _connection Is Nothing Then
>>            _connection = New OleDb.OleDbConnection(_connStr)
>>            _connection.Open()
>>        Else
>>            If _connection.State = ConnectionState.Open Then
>>            Else
>>                _connection.Open()<------- ERRROR HERE
>>            End If
>>        End If
>>    End Sub
>>
>
>

AddThis Social Bookmark Button