InvalidCastException in database constructor

InvalidCastException in database constructor

Postby Korhojuh » Wed 19 Aug 2015 12:24

Hello,
I was given job to continue work on MySQL entity framework project and the project had working 8.3.363.6 (or something like that) dotConnect version. It has been a while since project was touched and trial on the connector had expired (exception was thrown) so I decided to update the connector since it had been informing me about the update for a while.

After I downloaded and re-installed the dotConnector for MySQL 8.4.464 I started to get this error message when code hits database (empty) constructor:

Code: Select all
public DataStructureContext() : base("DB")
{
           
}


Code: Select all
[A]Devart.Data.MySql.Entity.Configuration.MySqlEntityProviderConfigurationSection cannot be cast to [B]Devart.Data.MySql.Entity.Configuration.MySqlEntityProviderConfigurationSection. Type A originates from 'Devart.Data.MySql.Entity, Version=8.4.464.0, Culture=neutral, PublicKeyToken=09af7300eec23701' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Devart.Data.MySql.Entity\v4.0_8.4.464.0__09af7300eec23701\Devart.Data.MySql.Entity.dll'. Type B originates from 'Devart.Data.MySql.Entity, Version=8.4.464.6, Culture=neutral, PublicKeyToken=09af7300eec23701' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Devart.Data.MySql.Entity\v4.0_8.4.464.6__09af7300eec23701\Devart.Data.MySql.Entity.dll'.


Error message it self is quite self explanatory, but I cannot underestand why project is using dll from C: drive (wrong version even) and then trying to convert it to version that is referenced to the project. I have not referenced the dll in windows folder.

Is this a problem with code? References? Expired trial?

I have put this provider in my app.config:
Code: Select all
<providers>
      <provider invariantName="Devart.Data.MySql" type="Devart.Data.MySql.Entity.MySqlEntityProviderServices, Devart.Data.MySql.Entity, Version=8.4.464.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </providers>
Korhojuh
 
Posts: 4
Joined: Wed 28 Jan 2015 10:50

Re: InvalidCastException in database constructor

Postby Shalex » Thu 20 Aug 2015 08:28

1. Please remove references to the Devart.* assemblies from your project and readd them again:
Devart.Data.dll v5.0.1256.0
Devart.Data.MySql.dll v8.4.464.0
Devart.Data.MySql.Entity.dll v8.4.464.6

2. Make sure that there are no references to v8.3.363 in your project.

3. Clear the bin and obj folders of your project, rebuild the project.

4. Run your project in the debug mode, navigate to Debug > Windows > Modules. What are Devart.* assemblies (and their exact versions) loaded in the process of your application?
Shalex
Devart Team
 
Posts: 7602
Joined: Thu 14 Aug 2008 12:44

Re: InvalidCastException in database constructor

Postby Korhojuh » Fri 21 Aug 2015 07:22

I was able to get through this this problem. I had missed single line in app.config with 8.3.363.6 reference which was the cause of this error.
Korhojuh
 
Posts: 4
Joined: Wed 28 Jan 2015 10:50


Return to dotConnect for MySQL