FileLoadException when Copy Local is set to true for Microsoft.Silverlight.Testing

Mar 13, 2013 at 10:59 AM
Hi! I'm using AgUnit with Resharper 7.1 in VS2012 with SL5 and nunit-silverlight. I'm trying to figure out how to make it possible for my tests to run both from AgUnit and from the browser.

The problem I'm having is that if I set Copy Local to false for Microsoft.Silverlight.Testing and Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight, my tests run in AgUnit fine. But when running them in browser, the browser crashes because these DLLs are missing. If I include them in the XAP, then I can run the test from the browser, but the AgUnit shows a message box saying that assembly version conflicts with the one bound in the app domain.

Image

After I click OK, according to AgUnit the tests is still running and it stays like that indefinitely. I have to manually stop it from Unit Test Sessions view.

I understand this exception comes from StatLight but strangely, if I run my test from StatLight command line, I only get this as a warning (yellow) but all tests run successfully.
********************* ReflectionTypeLoadException *********************
***** Begin Loader Exception Messages *****
   -  Could not load file or assembly 'Microsoft.Silverlight.Testing, Version=5.
0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
ies. The requested assembly version conflicts with what is already bound in the
app domain or specified in the manifest. (Exception from HRESULT: 0x80131053)
   -  Could not load file or assembly 'Microsoft.Silverlight.Testing, Version=5.
0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
ies. The requested assembly version conflicts with what is already bound in the
app domain or specified in the manifest. (Exception from HRESULT: 0x80131053)
   -  Could not load file or assembly 'Microsoft.Silverlight.Testing, Version=5.
0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
ies. The requested assembly version conflicts with what is already bound in the
app domain or specified in the manifest. (Exception from HRESULT: 0x80131053)
   -  Could not load file or assembly 'Microsoft.Silverlight.Testing, Version=5.
0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
ies. The requested assembly version conflicts with what is already bound in the
app domain or specified in the manifest. (Exception from HRESULT: 0x80131053)
   -  Could not load file or assembly 'Microsoft.Silverlight.Testing, Version=5.
0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
ies. The requested assembly version conflicts with what is already bound in the
app domain or specified in the manifest. (Exception from HRESULT: 0x80131053)

***** End Loader Exception Messages *****

...
*************** Summary ********************
********************************************
Total          : 3
Successful     : 3
Failed         : 0
Ignored        : 0
Completion End : 13.3.2013. 10:43:55
Duration       : 00:00:01.3826295
********************************************
Does anyone know what's the issue here? Or a way to work around this? Thank you!
Coordinator
Mar 13, 2013 at 1:38 PM
Edited Mar 13, 2013 at 1:39 PM
This is probably because there's an older version of StatLight included with AgUnit. (which is still loading the SL4 version of Microsoft.Silverlight.Testing.dll).

You can try replacing the StatLight.dll and all the .xap files in the AgUnit plugin folder with those from the latest StatLight.

I'll try reproduce this issue and create a new release.
Mar 13, 2013 at 2:58 PM
Thanks for the reply!

I experimented a bit and did something similar. I first made a backup of all StatLight.Client XAPs and removed them from the StatLight install folder. Then I copied back the newest one (StatLight.Client.For.MSTest2011December.xap) and renamed it to StatLight.Client.For.MSTest2010May.xap (as this if the XAP that StatLight uses to load my tests). This solved the problem from the command line (no more assembly version conflict messages).

Then I did the same in AgUnit install folder, I removed all other XAPs except the new one and renamed it to 2010May. (I did this with the XAPs already present in Plugins/AgUnit, I didn't copy the one from StatLight). And this solved the problem with running the tests from Resharper's Test runner from VS.

I see that in AgUnit install folder I also have every MSTest XAP with "-SL5" suffix. I didn't have the time to experiment with them so I'm not sure if AgUnit's StatLight doesn't use them at all or there is another issue.

I would really like to know if you can reproduce this and how to properly fix the problem. My solution works but I'm not very comfortable with voodoo solutions as I have no idea if I broke something else now. :) Thanks!
Coordinator
Mar 13, 2013 at 4:38 PM
Can you give me the file versions (Not the assembly version, because that will be either 2.0.5.0 or 5.0.5.0 and completely meaningless) of Microsoft.Silverlight.Testing and Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll ?

You can find those by going to the file properties in windows explorer and looking at the details tab.
Mar 13, 2013 at 6:55 PM
Of course! The ones that I have referenced in my SL test project are from SL Toolkit (dec11)
Microsoft.Silverlight.Testing.dll is 5.0.60818.0 and
Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll is 5.0.60818.0 also.