Unable to cast object of type 'Npgsql.NpgsqlConnection' to type 'Npgsql.NpgsqlConnection'.

Posts   
 
    
ericdes
User
Posts: 19
Joined: 09-Aug-2008
# Posted on: 09-Aug-2008 15:27:40   

I'm following your tutorial for Linq to LLBLGen Pro.


            using (var adapter = new DataAccessAdapter())
            {
                LinqMetaData metaData = new LinqMetaData(adapter);
                var q = from c in metaData.Country
                        where c.CountryCode == "US"
                        select new
                        {
                            c.CountryName
                        };

                int count = 0;
                foreach (var v in q)
                {
                    count++;
                }
 .....
            }

and I'm getting this error:

Unable to cast object of type 'Npgsql.NpgsqlConnection' to type 'Npgsql.NpgsqlConnection'.

Configuration: VS2008/SP1Beta1 .Net 3.5 SP1 LLBLGen Pro 2.6 Final 6/6/2008 Npgsql2.0rc1-bin-ms.net3.5sp1beta

Am I using the right PostgreSQL .net driver?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 09-Aug-2008 16:10:14   

Could you simply reference the npgsql dll in the Drivers\Postgresql folder? That's not the RC build you're using and the DQE is build agains that 1.0 version, not the 2.0 version. You might also solve this with an assembly redirect in your application's config file for the npgsql dll

Frans Bouma | Lead developer LLBLGen Pro
ericdes
User
Posts: 19
Joined: 09-Aug-2008
# Posted on: 09-Aug-2008 17:23:36   

I went back to reference Npgsql with the 1.0.0 version taken from Drivers\PostgreSql. But for some reason ORDBSpecific was referenced with the newer version. I'm not even sure how I did that. How do I specify which Npgsql version I want to use in LLBKGenPro?

Error 5 Assembly 'ORDBSpecific, Version=1.0.3143.12884, Culture=neutral, PublicKeyToken=null' uses 'Npgsql, Version=1.99.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' which has a higher version than referenced assembly 'Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' d:\Dev\TelaERP\OR\DatabaseSpecific\bin\Debug\ORDBSpecific.dll TelaERP

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 11-Aug-2008 09:02:07   

Please try using an assembly redirect in your application's config file for the npgsql dll.

ericdes
User
Posts: 19
Joined: 09-Aug-2008
# Posted on: 13-Aug-2008 17:03:12   

I solved the problem by removing all Npgsql.dll release 2 from my hard drive.