tags:

views:

507

answers:

1

Heya, I'm currently trying to get bltoolkit working in my project. I've added the BLToolkit.3 project to my solution and am referencing it appropriately.

The code in question is really simple.

    public List<Account> LoadAccounts()
    {
        using (DbManager db = new DbManager("MySql"))
        {
            var query = new SqlQuery<Account>();
            return query.SelectAll(db);
        }
    }

With an app.config of

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="bltoolkit" type="BLToolkit.Configuration.BLToolkitSection, BLToolkit.3"/>
  </configSections>

  <bltoolkit>
    <dataProviders>
      <add type="BLToolkit.Data.DataProvider.MySqlDataProvider" />
    </dataProviders>
  </bltoolkit>

  <connectionStrings>
    <add name="MySql" connectionString="Server=localhost;Port=3306;Database=BLT;Uid=root;" providerName="MySql.Data.MySqlClient"/>
  </connectionStrings>
</configuration>

When I try to run that, I get the following exception: "The type initializer for 'BLToolkit.Data.DbManager' threw an exception."

Upon closer inspection it seems to be line 261 in DbManager.Config.cs

Type             dataProviderType = Type.GetType(provider.TypeName, true);

Which basically fails to get the MySQL providers type. I've tried putting the MySQL.data.dll in my applications run path, with no luck.

Any ideas?

+2  A: 

By default, MySqlDataProvider is not included in build. You'll have to download source code and add MySqlDataProvider.cs as "Existing Item" to your project (and modify assembly-qualified type name appropriately). Or, if you're fine with recompiling BLTooklit, you can include it in BLToolkit project itself.

Anton Gogolev
Aaaah, I see. Set it to compile the MySQLProvider and removed strong naming and now it's working great thanks :)
Fauxide
Is the same thing true for Oracle using ODP.net?
JayG
@JayG, Yes it is, you need to do the same when using odp.net .
Theo