FileLoadException

B

Berryl Hesh

Goal:
Use an example project I found which illustrates use of design patterns that
facilitate unit testing, so I can incorporate these patterns into my own
projects. One pattern is built on NHibernate. The dll for nhibernate which
came with the project was version v1.1.4322, as the sample code is almost a
year old. The NHibernate dll I downloaded is v2.0.50727.

Problem(s):
* I could not get this one project of several to complile, so I started to
migrate the entire solution to a new solution using updated versions of the
dependent dlls, like NHibernate.This worked well for several dependent
projects I needed to compile and test prior to this one.
* After migrating this sub-project to my new solution builds fine, but when
I run a test that uses NHibernate, I get:
"Could not load file or assembly 'NHibernate, Version=1.2.0.4000,
Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its
dependencies. The located assembly's manifest definition does not match the
assembly reference."

How can I fix this??

Why is my test looking for v1.2 in the first place. The reference dll it's
built on s/n 2.0. I looked in the GAC but didn't see any NHibernate
assemblies there.

Thanks for any help! BH
 
J

Jon Skeet [C# MVP]

Berryl Hesh said:
Goal:
Use an example project I found which illustrates use of design patterns that
facilitate unit testing, so I can incorporate these patterns into my own
projects. One pattern is built on NHibernate. The dll for nhibernate which
came with the project was version v1.1.4322, as the sample code is almost a
year old. The NHibernate dll I downloaded is v2.0.50727.

Those sound very unlikely numbers - they are the version numbers of the
..NET framework itself. It's unlikely that NHibernate just happened to
use the same minor version numbers.
Problem(s):
* I could not get this one project of several to complile, so I started to
migrate the entire solution to a new solution using updated versions of the
dependent dlls, like NHibernate.This worked well for several dependent
projects I needed to compile and test prior to this one.
* After migrating this sub-project to my new solution builds fine, but when
I run a test that uses NHibernate, I get:
"Could not load file or assembly 'NHibernate, Version=1.2.0.4000,
Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its
dependencies. The located assembly's manifest definition does not match the
assembly reference."

How can I fix this??

Why is my test looking for v1.2 in the first place. The reference dll it's
built on s/n 2.0. I looked in the GAC but didn't see any NHibernate
assemblies there.

Not sure what you mean by "s/n" there.
 
B

Berryl Hesh

You're right about the numbers being CLR versions. The version of NHibernate
refernce in the project is 2.0.0.4000. My question is where is the old
version 1.2.0.4000 in the error message is coming from?
 
J

Jon Skeet [C# MVP]

Berryl Hesh said:
You're right about the numbers being CLR versions. The version of NHibernate
refernce in the project is 2.0.0.4000. My question is where is the old
version 1.2.0.4000 in the error message is coming from?

That does seem odd. What does the stack trace look like? That might
show what's expecting 1.2.0.4000. The fact that the "4000" is the same
in both cases is somewhat suspicious.
 
B

Berryl Hesh

(Exception from HRESULT: 0x80131040)

I am thinking it's some configuration type of problem. I get the same error
if I exclude the config file that came with the code, and the code near the
start of the error is trying to load that file too.

Here's the stack trace
x--------------------x
at
Castle.ActiveRecord.ActiveRecordStarter.SetUpConfiguration(IConfigurationSource
source, Type type, ISessionFactoryHolder holder)
at Castle.ActiveRecord.ActiveRecordStarter.Initialize(IConfigurationSource
source, Type[] types)
C:\Documents and Settings\Berryl\My Documents\Visual Studio
2008\Projects\Learning\Lab\OMG.DataAccess\OMG.DataAccess\DataAccessHelper.cs(23,0):
at OMG.DataAccess.DataAccessHelper.Initialize()
C:\Documents and Settings\Berryl\My Documents\Visual Studio
2008\Projects\Learning\Lab\OMG.DataAccess\OMG.DataAccess\Repository\RepositoryBase.cs(19,0):
at OMG.DataAccess.Repository.RepositoryBase`2..ctor()
at OMG.DataAccess.Repository.CustomerRepository..ctor()
C:\Documents and Settings\Berryl\My Documents\Visual Studio
2008\Projects\Learning\Lab\OMG.DataAccess.Tests\OMG.DataAccess.Tests\CustomerRepositoryTest.cs(19,0):
at OMG.DataAccess.Tests.CustomerRepositoryTest.Setup()

Here's the method where the error starts in DataAccessHelper
x--------------------x
19 public static void Initialize() {
20 if (DataAccessHelper._source != null) return; (_source is a
XmlConfigurationSource field)
21 ActiveRecordStarter.SessionFactoryHolderCreated +=
ActiveRecordStarter_SessionFactoryHolderCreated;
22 _source = new XmlConfigurationSource("../../appconfig.xml");
23 ActiveRecordStarter.Initialize(_source, typeof(Customer),
typeof(Order));
}

Here's appconfig.xml
x--------------------x
<activerecord>
<config>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver" />
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect" />
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider" />
<add
key="hibernate.connection.connection_string"
value="Data Source=.;Initial Catalog=Northwind;Integrated Security=SSPI" />
</config>
</activerecord>
 
J

Jon Skeet [C# MVP]

Berryl Hesh said:
(Exception from HRESULT: 0x80131040)

I am thinking it's some configuration type of problem. I get the same error
if I exclude the config file that came with the code, and the code near the
start of the error is trying to load that file too.

Okay, I suggest you have a look at the Castle DLLs to see whether they
reference v1.2.0.4000. That looks like the most likely candidate.

The other thing that you can do is turn on the fusion log (search for
details) which I *think* explains why assemblies are loaded.
 
B

Berryl Hesh

Using ildasm I can see in Castle.ActiveRecord's manifest the explanation for
the error:
.assembly extern NHibernate
{
.publickeytoken = (AA 95 F2 07 79 8D FD B4 ) // ....y...
.ver 1:2:0:4000
}

It seems like a pretty popular solution, so I'm surprised there isn't a
build incorporation NHibernate's newest release, or even some mention of it.
So now I have to decide whether to use the older NHibernate dll (this sounds
confusing if ever the newer one's features become desireable), or try to
make an ActiveRecord build myself with the new NHibernate (sounds like
trouble, and if it were easy I would find it somewhere

Thanks again for your help - BH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top