unable to retrive UniException.InnerException.Code from Mysql provider

unable to retrive UniException.InnerException.Code from Mysql provider

Postby novice » Mon 29 Aug 2016 21:31

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 [B] 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
novice
 
Posts: 3
Joined: Mon 29 Aug 2016 21:06

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

Postby Pinturiccio » Wed 31 Aug 2016 14:39

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/library/system.type.assemblyqualifiedname(v=vs.110).aspx
Pinturiccio
Devart Team
 
Posts: 2021
Joined: Wed 02 Nov 2011 09:44

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

Postby novice » Wed 31 Aug 2016 22:18

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/library/system.type.assemblyqualifiedname(v=vs.110).aspx


Hello again,
how can I take this value (UniException.InnerException.Code)?
novice
 
Posts: 3
Joined: Mon 29 Aug 2016 21:06

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

Postby Shalex » Thu 01 Sep 2016 15:45

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 http://forums.devart.com/viewtopic.php?f=4&t=20560.
Shalex
Devart Team
 
Posts: 7780
Joined: Thu 14 Aug 2008 12:44

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

Postby Shalex » Thu 22 Sep 2016 16:20

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.
Shalex
Devart Team
 
Posts: 7780
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect Universal