VansFannel
VansFannel

Reputation: 45911

Can't load assembly from GAC but it loads from program's folder

I'm developing a C# application with .NET Framework 4.0, Entity Framework 6.1.3 and Sqlite 1.0.96.0.

I have an assembly that use SQLite, MyCompany.Data.Sqlite.Common, installed on GAC (System.Data.SQLite is also installed on GAC).

I have two errors:

'Entity Framework used the default instance DbConfiguration before the type was detected' SQLiteConfiguration '. An instance of 'SQLiteConfiguration' should be set at the beginning of the application before using any feature or Entity Framework must be registered in the configuration file of the application. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information. '

To fix this, I have add the following in App.config:

<entityFramework codeConfigurationType="MyCompany.Data.Sqlite.Common.SQLiteConfiguration, MyCompany.Data.Sqlite.Common">

But, after adding this to App.config the program it doesn't load it from GAC.

I have to copy the same dll into EXEC folder to load it and run the program.

I think this is not a version number problem or the dll has a bad format, because I'm using the same dll in GAC.

I have also added this to App.config:

<dependentAssembly>
        <assemblyIdentity name="MyCompany.Data.Sqlite.Common" publicKeyToken="db937bc2d44ff139" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
      </dependentAssembly>

But I have to copy the dll to application's folder.

Any idea?

Upvotes: 0

Views: 726

Answers (1)

Kinexus
Kinexus

Reputation: 12904

Loading assemblies from the GAC needs the fully qualified assembly name. For example;

<entityFramework codeConfigurationType="MyCompany.Data.Sqlite.Common.SQLiteConfiguration, MyCompany.Data.Sqlite.Common, Version=1.1.1.1, Culture=neutral, PublicKeyToken=ABCD1234567890">

Upvotes: 2

Related Questions