Page 1 of 1

unable to retrive UniException.InnerException.Code from Mysql provider

Posted: Mon 29 Aug 2016 21:31
by novice
Hi,
On debugging i'm able to see the code "203" (Can't connect to MySql server...) on "UniException.InnerException.Code" on debug, but im not able to retrive this value.

here is my code:

Code: Select all

Try
            Dim con As UniConnection = New .UniConnection("provider=MySQL;Server=fake ip;Database="abcd";Uid=root;Pwd=root;Connection Timeout=1")
            con.Open()


        Catch ex As UniException


            Dim exType As Type = ex.InnerException.GetType()
            Select Case exType.FullName
                Case "Devart.Data.MySql.MySqlException"
                    Dim code As Integer = DirectCast(ex.InnerException, Devart.Data.MySql.MySqlException).Code

            End Select

        End Try
I get the following error (translated from italian operating system):
"Unable to cast [A] Devart.Data.MySql.MySqlException to Devart.Data.MySql.MySqlException. The type A has originated from 'Devart.Data.Universal.MySql, Version = 3.60.1211.0, Cultures = neutral, PublicKeyToken = 09af7300eec23701 'in the' Default 'setting in the' C: \ WINDOWS \ assembly \ GAC_MSIL \ Devart.Data.Universal.MySql \ 3.60.1211.0__09af7300eec23701 \ Devart.Data.Universal.MySql.dll '. The type B originates from 'Devart.Data.MySql, Version = 8.6.714.0, Culture = neutral, PublicKeyToken = 09af7300eec23701' in the 'Default' setting in the 'C: \ WINDOWS \ assembly \ GAC_MSIL \ Devart.Data.MySql \ 8.6. 714.0__09af7300eec23701 \ Devart.Data.MySql.dll '. "

I'm using vb.net on .net 4.5 with the latest dcuniversal 3.60.1211 and dc mysql 8.6.714

Re: unable to retrive UniException.InnerException.Code from Mysql provider

Posted: Wed 31 Aug 2016 14:39
by Pinturiccio
This is a designed behavior. The reason is that the inner exception of UniException has the MySqlException type. But this type is located in Devart.Data.Universal.MySql.dll and thus, the inner exception cannot be cast to the MySqlException type from the Devart.Data.MySql.dll assembly.

You can see that your inner exception is a type of Devart.Data.Universal.MySql assembly in the AssemblyQualifiedName property of your exType variable. For more information, please refer to https://msdn.microsoft.com/en-us/librar ... .110).aspx

Re: unable to retrive UniException.InnerException.Code from Mysql provider

Posted: Wed 31 Aug 2016 22:18
by novice
Pinturiccio wrote:This is a designed behavior. The reason is that the inner exception of UniException has the MySqlException type. But this type is located in Devart.Data.Universal.MySql.dll and thus, the inner exception cannot be cast to the MySqlException type from the Devart.Data.MySql.dll assembly.

You can see that your inner exception is a type of Devart.Data.Universal.MySql assembly in the AssemblyQualifiedName property of your exType variable. For more information, please refer to https://msdn.microsoft.com/en-us/librar ... .110).aspx
Hello again,
how can I take this value (UniException.InnerException.Code)?

Re: unable to retrive UniException.InnerException.Code from Mysql provider

Posted: Thu 01 Sep 2016 15:45
by Shalex
The current access modifier for Devart.Data.MySql.MySqlException in Devart.Data.Universal.MySql.dll is internal. We will notify you when it is changed to public.

JIC: a similar issue (but for Devart.Data.Oracle.OracleException) was discussed at viewtopic.php?f=4&t=20560.

Re: unable to retrive UniException.InnerException.Code from Mysql provider

Posted: Thu 22 Sep 2016 16:20
by Shalex
Starting from v3.60.1240 of dotConnect Universal, the behaviour is changed: the Devart.Data.MySql.MySqlException class from Devart.Data.Universal.MySql.dll is public now.