nUnit fails to load assembly ESRI.ArcGIS.Version

09-22-2011 02:32 AM
New Contributor
Hello Unit Testers,

I'm experimenting with MSTest (via VS2010) and nUnit for building .NET class libraries for large modular applications using Arc 10.  My main problem is described in the title, but since there's not a great deal of information on the subject I'd like to share a little of my experiences so far as part of the setup to my question.  (But if you just want to get to the point, you can go straight to the end of the post 🙂

My goal is to have an automated build process check out the sources and run the unit tests.  I also want to be able to test 'internal' classes (internal scoped constructors), but I'm not looking to test private methods.  Based on various readings, this appears to be the most robust setup for the long term.

MSTest works except for testing internal classes, which is a serious drawback.  The problem is that it seems to require a separate project externally referencing the class library under test.  For example, if you write some code and want to create a test, adding a new test in VS2010 actually creates a new project containing a template unit test class and adds it to the class lib solution.  (A variety of readings around the web indicate other less serious issues relating to MS's infamous version instability, as well as clarity of expressions, among others).  One interesting quirk is that, for me, the license manager only works when the tests are run in multi-threaded mode, unlike the discussion here suggests.  Otherwise, an error is thrown indicating that the RCW has been separated from the underlying COM object.  There are some helpful discussions here and here.  Based on these discussions, multi-threaded tests are the way to go for the short term, but it might be worth figuring out STA if this becomes the test environment for the long term.

nUnit has a lot of good opinions around the web, and easily accommodates tests within the class library, and therefore tests that instantiate internal classes.  This would be my preferred route, except that Arc licensing fails when I run the tests.

The licensing fails just at the point of initializing the products, while trying to load the ESRI.ArcGIS.Version assembly.  The exact message is:
"Could not load file or assembly 'ESRI.ArcGIS.Version, Version=, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86' or one of its dependencies. The system cannot find the file specified.":"ESRI.ArcGIS.Version, Version=, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86"

My licensing code is adapted from the LicenseInitializer snippet available in the console application template.  For example, create a new console application in VS, then click the Project menu, then "Add ArcGIS License Checking".  I'm confident the methodology is not a problem, plus there's the fact the same code works under MSTest.

So if anyone has any idea why nUnit might be failing here I'd be very grateful for your insights.  And of course comments on any of the above points are most welcome.


0 Kudos
1 Reply
Regular Contributor III
Use fuslogvw to diagnoise assembly loading problems.
0 Kudos