开发者

How do I set the absolute path for a assembly containing Database connector? MySQL Connector 6.4.3 with Entity Framework 4.1

Reason why: http://bugs.mysql.com/bug.php?id=61933

I recompiled the connector from source, incremented tit a version to 6.4.3.1, but now this (possibly) trivial question blocks me.

How do I set the full provider name in the connection string in app.config? I have the official 6.4.3 connector installed.

The error I get is when I add a new entity data model, and select from an existing database. This I traced to the above linked (silly) bug.

I couldn't find a better title for this question.


Microsoft Visual Studio

An error occurred while connecting to the database. The database might be unavailable. An exception of type 'System.Data.ProviderIncompatibleException' occurred. The error message is: 'The provider did not return a ProviderManifestToken string.

The inner exception caught was of type 'System.FormatException', with this error message: 'Input string was not in a correct format.'.'.

OK


Solution

  1. Download MySQL Connector/6.4.3 sources, and extract it.

  2. In the MySql.Data.Entity project, replace...:

  3. (ProviderServices.cs:188) With: double version = double.Parse(connection.ServerVersion.Substring(0, 3), System.Globalization.CultureInfo.InvariantCulture);

  4. (ProviderManifest.cs:73) With: double version = double.Parse(manifestToken, System.Globalization.CultureInfo.InvariantCulture);

  5. Create a new sign key and name it ConnectorNet (same name as in the assemblyinfo.cs)

  6. Add .1 to the AssemblyVersion in AssemblyInfo.cs in the MySql.Data project, this 1 file is shared with the rest: [assembly: AssemblyVersion("6.4.3.1")]

  7. Put Release as target configuration, you can also disable the .Tests projects from being built.

  8. As admin, install them with gacutil. Here you also get the public key token.

  9. Locate Machine.config note it is important to know what .NET fx you compiled the project(s) to use.

  10. Search for DbProviderFactories, and comment out the existing MySQL Data Provider, copy it开发者_如何学C and replace in the duplicate entry, by adding the .1 in version and the public key token.

<!-- add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" / -->

<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.3.1, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXXXX" />


Connection string doesn't contain path to provider assembly. Connection string's providerName is only reference to provider registered in system.data\DbProviderFactories:

<system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" 
           invariant="MySql.Data.MySqlClient" 
           description=".Net Framework Data Provider for MySQL"  
           type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.3.1, Culture=neutral, PublicKeyToken=YourToken" />
</system.data>

The invariant from factory registration is what you reference in providerName of connection string. You can try to put your new connector assembly to your application directory or strongly name the assembly install it to GAC.


Simpler solution: use the official 6.4.3 installer.

Go in your regional settings, change your decimal separator from ',' to '.' et voilà.

It's enough while waiting for the 6.4.4 to ship.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜