0

I setup an object context like this:

public MyObjectContext(....) : this(contextName, new EntityConnection(connectionString))

The connection string is a connection string to an Oracle database. I use DevArt as a provider btw.

Everything works fine. I can use it to retrieve entities etc.

But then I wanted to do something with the underlying connection. I did something like:

(OracleConnection)((EntityConnection)context.Connection.StoreConnection)

Which gives me the following exception:

SystemInvalidCastException: [A]Devart.Data.Oracle.OracleConnection cannot be converted to [B]Devart.Data.Oracle.OracleConnection. .... Type A is from C:\Windows\....\6.60.283\.... Type B is from C:\DevDirectory\...\7.2.104.0

It seems that the ObjectContext uses an old version of the DLL. However if I check the references of my project I see a reference to the correct version 7.2.104.0. As I checked further the ObjectContext can still connect even if I have no reference at all in the Subproject where its class is.

How does it resolve the DLL it uses to connect?

patrickuhlmlann
  • 342
  • 2
  • 4
  • 14
  • It seems that the old version is still in the GAC. – Gert Arnold Jan 22 '13 at 21:27
  • Does this mean the Entity Framework does look for the DLL in the GAC first even if there is a reference to a newer version in the project itself? Seems strange to me... – patrickuhlmlann Jan 22 '13 at 22:36
  • No, but there may be a reference to the new version in the project (assembly) where you do the cast, whereas the assembly containing the EF types was built with the the older (GAC) version. Assuming that they are separate assemblies. – Gert Arnold Jan 22 '13 at 23:20

1 Answers1

0

Yeah I just realized that I still had the wrong version (6) of devArt installed (globally) but referenced the right version (7) in the project. The assembly containing the ObjectContext had no reference so it needed to get the version from the GAC which was the old one (6).

Thx. For the clarification.

patrickuhlmlann
  • 342
  • 2
  • 4
  • 14