Agatha and StructureMap ... Version problem? 2.6.3,0 and 2.6.4.1

598 views
Skip to first unread message

shapper

unread,
Aug 26, 2012, 4:20:18 PM8/26/12
to agath...@googlegroups.com
Hello,

I am installing Agatha-ServiceLayer-StructureMap 1.3.1 on a Test project and when I run a test I keep having the following error:

Could not load file or assembly 'StructureMap, Version=2.6.3.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

On the App.Config I have the following:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="StructureMap" publicKeyToken="e60ad81abae3c223" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.6.4.0" newVersion="2.6.4.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

The project builds but the test does not run due to the error I mentioned.

Any idea how to solve this?

Thank You,
Miguel

Mark Meyers

unread,
Aug 26, 2012, 4:24:06 PM8/26/12
to agath...@googlegroups.com
typo in the app.config ?
shouldn't :
<bindingRedirect oldVersion="0.0.0.0-2.6.4.0" newVersion="2.6.4.0" />
be :
<bindingRedirect oldVersion="0.0.0.0-2.6.3.0" newVersion="2.6.4.0" />

shapper

unread,
Aug 26, 2012, 4:26:23 PM8/26/12
to agath...@googlegroups.com
The binding redirect was placed in App.Config when installing the packages.

But I tried your suggestion before and didn't work ...

Mark Meyers

unread,
Aug 26, 2012, 4:31:12 PM8/26/12
to agath...@googlegroups.com
are you using automocking in your test ?

shapper

unread,
Aug 26, 2012, 4:36:15 PM8/26/12
to agath...@googlegroups.com
No ... In this case it is not even a real test method.

I am just creating some dummy data on a database.

I have tried the usual solutions for the past 24 hours:
Delete DLLs, reinstall the packages, delete Temp ASP.NET files, etc ...

But I am not able to solve this ... In fact I fond the same problem with NServiceBus:

http://tech.dir.groups.yahoo.com/group/nservicebus/message/15462

But I can't find a solution that solves this ...

Mark Meyers

unread,
Aug 26, 2012, 5:01:42 PM8/26/12
to agath...@googlegroups.com
well, I think I'm out of my league here, but I'll try :

what's the actual version of the structuremap dll ?
strangely enough there is no 2.6.4.0 in the nuget library so it might help to change the assembly redirect to the actual version, 2.6.4.1 perhaps ?

what testing framework are you using ?
does it work in a console app ?

shapper

unread,
Aug 26, 2012, 5:23:08 PM8/26/12
to agath...@googlegroups.com
The file version of StructureMap is 2.6.4.1 and the product version is 2.6.4.0.

I am using Visual Studio 2012 testing framework.
And I am targeting NET 4.5.

I created a console application and it works fine. I get this error only on the Test project.

I have no idea what might be wrong.

Mark Meyers

unread,
Aug 26, 2012, 5:31:55 PM8/26/12
to agath...@googlegroups.com
aha , maybe it's this, I ran into this a while ago

MSTest copies the files into a temporary folder when running tests, sometimes it misses out on references (especially IoC ones and plugin kinds of things). 
if I remember correctly there are ways to tell MSTest explicitly which dlls are required.

although i would suggest using a different testing framework in order to avoid this hassle ;-)

shapper

unread,
Aug 26, 2012, 5:32:24 PM8/26/12
to agath...@googlegroups.com
Hello,

I created a console application and a test project.

I installed Agatha-ServiceLayer-StructureMap 1.3.1 in both projects the same way.

I used the same code in the Main of Console application and in the Test method.

I get the error on the Test and not on the Console application.

Any idea?

Thank You,
Miguel

Mark Meyers

unread,
Aug 26, 2012, 5:35:13 PM8/26/12
to agath...@googlegroups.com
if above suggestion is indeed the problem another workaround might be :
-  try explicitly instantiating a StructureMap class in your test, that way MSTest picks up the reference and will copy the dll.

shapper

unread,
Aug 26, 2012, 5:50:49 PM8/26/12
to agath...@googlegroups.com
I tried explicitly instantiating a StructureMap class in the test but didn't solved it ...

Do you have an idea where the MSTests temp folder that you mentioned is?

When I build the test project the StructureMap.dll version 2.6.4.1 is copied to the bin/debug folder.

So I really have no idea what is going on ... Maybe the 2.6.3 version is cached somewhere?


On Sunday, August 26, 2012 9:20:18 PM UTC+1, shapper wrote:

Mark Meyers

unread,
Aug 26, 2012, 6:01:16 PM8/26/12
to agath...@googlegroups.com
nah there's an 'out' folder somewhere, but it get's deleted after the tests have run, it's a real pain.


apparantly there's a way to run test's in place aswell now

Still you're better off without all that and just nunit or xunit.net ;-)

shapper

unread,
Aug 26, 2012, 9:19:14 PM8/26/12
to agath...@googlegroups.com
No luck for now ...

I am really considering using XUnit. What annoys me is that I can't use VS 2012 IDE with it ...

I even turned on Fusion Log Viewer and get the following error:

=== Pre-bind state information ===
LOG: User = Fly\Miguel
LOG: DisplayName = StructureMap, Version=2.6.3.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223
 (Fully-specified)
LOG: Appbase = file:///C:/Users/Miguel/Desktop/TEMP/UnitTestProject1/UnitTestProject1/bin/Release
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : UnitTestProject1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Miguel\Desktop\TEMP\UnitTestProject1\UnitTestProject1\bin\Release\UnitTestProject1.dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: StructureMap, Version=2.6.3.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/Miguel/Desktop/TEMP/UnitTestProject1/UnitTestProject1/bin/Release/StructureMap.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\Miguel\Desktop\TEMP\UnitTestProject1\UnitTestProject1\bin\Release\StructureMap.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: StructureMap, Version=2.6.4.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated

I am not sure but might this be an Agatha package problem created by the StructureMap new version?

Aaron Fischer

unread,
Aug 26, 2012, 11:54:19 PM8/26/12
to agath...@googlegroups.com
looks like something wants to load the 2.6.3.0 version of structuremap, and your supplying 2.6.4.1 which means you need to add a binding redirect in your unit test projects app.config so the framework knows it can use the newer version.


shapper

unread,
Aug 27, 2012, 9:47:24 AM8/27/12
to agath...@googlegroups.com
Well,

I tried everything I could find and all suggestions to try to solve this an no luck.

So I downloaded Agatha project and updated all packages using Update-Package.

There are a few packages needing update ...

I rebuilt the Agatha packages and used those on my Test project.

Now everything is working fine ...

Maybe someone could update all packages on the Github project?

---
 
Thank You,
Miguel
Reply all
Reply to author
Forward
0 new messages