in

NIMTUG

Northern Ireland Microsoft Technologies User Group

Damien McGivern

Could not load file or assembly nunit.core

I recently upgraded to the latest version of NUnit (2.2.8) [1] and when I ran some tests on a library I’m currently working on using TestDriven.Net I got the following error (error #1).

“Could not load file or assembly ‘nunit.core, Version=2.2.6.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77’ or one of its dependencies. The system could not find the specific file.”

System.IO.FileNotFoundException...
   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
   at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
   at NUnit.Util.TestDomain.MakeRemoteTestRunner(AppDomain runnerDomain)
   at NUnit.Util.TestDomain.Load(String assemblyFileName, String testFixture)
   at NUnit.Util.TestLoader.LoadTest(String testName)


My first initial thought was that the install had gone wrong as it mentioned version 2.2.6.0 – not 2.2.8.0. After I googled the problem I found a thread on TestDriven.Net User Google group [2], where what seemed to be the same problem was being discussed. The solution offered in this thread was to check the reference to nunit.framework was the correct version and recompile. Unfortunately this didn’t work and google was out of answers :( 

Now I’m back to my initial thinking that it might be an install error so I open up the NUnit GUI directly and got the same error but this time the version number was 2.2.8.0 (error #2). This confused me even more as to what the problem was but convinced me that there was a problem with the install as I’d opened it up directly with out any tests, or had I. After uninstalling and reinstalling NUnit version 2.2.8.0 I opened up the NUnit GUI first and the error had gone, problem solved right? But when I ran the test directly with the GUI I get error #2 again!

After checking the options in the GUI, I realised that it loads the last library at start up (even if there's an error), which meant that my library was being loaded even when I opened the GUI directly, so out went the install problem idea – it had to be my library that I was testing. I decided to remove tests one by one but I first renamed the app.cofig file and ran nunit only to get an exception related to the config settings being missing. Before going on my little adventure I’d trailed through the config file (it was only a few lines in length) and was convinced that it was correct – but after closer inspection I discovered a single character was missing in a configSections section name. After correcting the spelling the tests ran (and passed) with out any problems.

I would have thought that nunit would have been able to handle congfig errors related to the loaded library being tested and display a more meaningfully error and that if a library fails to load that it wouldn’t be reloaded on startup again.

[1] http://www.nunit.org/

[2] http://groups.google.com/group/TestDrivenUsers/browse_thread/thread/82a6d4c7d5b50ddd/875747b90308af8f


Published May 17 2006, 11:18 by Damien McGivern
Filed under:

Comments

 

Fritz Schenk said:

Very clear
July 4, 2006 10:00
 

Yaroslav Mygach said:

Thanks a lot it really helps. I've got same issue today. After I fixed test application config file nunit start working properly.
July 7, 2006 3:43
 

Marcus Widerberg said:

I am having the same config issue. NUnit thinks my config is so unhip now that it is version 2.2.8. Older NUnit versions have played nicely with it, so it's totally lost its self-esteem. Haven't found the problem in the config yet though.
July 10, 2006 12:56
 

dan b said:

you hit my problem nail on the head.  nice post.  thanks
July 10, 2006 10:57
 

Pascal G. said:

Hi,

I had the exact same problem with the exception that the tests was working within the VS IDE (TestDriven.NET) but not with the NUnit GUI.

Thanks to this post, I looked at my config file and finally diagnose that french characters in XML Comments were causing the problem.  For example, as soon as I add a comment like:
<!-- bla bla é -->   it crashes.
if I replace it by
<!-- bla bla e -->  it works....
July 14, 2006 3:04
 

Janssens Luc said:

I had te same problem with error#2.
I had changed my App.config, added some paths in there.
after checking my App.config it seemed to be a fault in the construction of the string.
"c:\stuff & others" should be "c:\stuff amp; others" and problem was solved.

Thanks, for the hint!!!!
July 18, 2006 9:15
 

config dummy said:

AGGHH excactly the same problem!!! cost me 2 hours!

Tanxxxx!
August 3, 2006 12:48
 

Deasy said:

Your opinion bright up my day. Thank you. The key is app.config.
Obviously NUnit test convey confusing error message for me.
You save my whole day. Thank you.
August 4, 2006 3:27
 

Rohit said:

Thnaks dear,
                  I read your post and it helped...i removed the line from the web.config
which loads the assembly deleted the reference to the dll. Again after referencing the dll, it works fine.
Rohit
September 7, 2006 6:33
 

Bryan W. Young said:

Thanks for the tip.  Once I checked my app.config file, I found the problem.
October 2, 2006 8:37
 

Paul Lockwood said:

Thanks, this post led me straight to our issue.
October 25, 2006 3:38
 

Bgmate said:

I added this to app.config and then it gave this error.
 <appSettings>
   <add key="WebServiceURL"
        value="http://xxx.xx/customer/customerservice.asmx"/>
 </appSettings>

When I removed it. It works again.

Thx for this thread
October 27, 2006 8:44
 

Jagdish said:

Jsut put your

<appSettings>
  <add key="WebServiceURL"
       value="http://xxx.xx/customer/customerservice.asmx"/>
</appSettings>

at the bottom of the app.config file and it will work


Jagdish
January 8, 2007 9:26
 

Shehzad Sheikh said:

I was getting the same error too and nothing seemed to work for me... then i realized that nunit.framework.dll was missing in my projects debug folder. I just copied it and tried runnig the test again... booom it went ..:)

August 24, 2007 11:59
 

Judah said:

Hmmm, tough one. I'm getting the same error (both in the NUnit GUI as well as within TestDriven.NET.

What's odd is, it only happens on some of our machines.

I tried fixing it like the Google Groups post said, didn't work. Found your solution posted here -- unfortunately I don't have a .config file for the dll I'm testing; no config files in play here at all, as far as I can tell.

Any other ideas?

October 1, 2007 11:30
 

Damien McGivern said:

What version of NUnit and TestDriven.Net are you using Judah? Make sure all the machines have the correct/same version of NUNit installed as if you specify the version number and you have a different version you may get this error also.

October 2, 2007 10:08
 

Yusef said:

I got this issue after upgrading my version;  It was working for other team members but not me.  I was able to fix this issue by running Clean Solution within Visual Studio, then rebuild all.  That seemed to fix my issue.

May 23, 2008 8:15
 

Arvind said:

I solved the problem by copying the nunit.framework.dll into the debug folder and ran the tests successfully. Thanks Shehzad and Everyone.

July 26, 2008 2:35
 

Shahidul said:

Oh GOD, I just spent 2 days, there was no problem in app.config file, but unintentionally i kept bakup of config file in the same directory ( like bak_app.config), removed it problem solved.

December 4, 2008 10:44

Leave a Comment

(required)  
(optional)
(required)  
Add

About Damien McGivern

Hi I’m currently the Solutions Architect at Aurion Ltd who specialise in E-Learning solutions, which is based in Belfast. I’m a founding member of NIMTUG and am currently its group coordinator as well as a member or the Irish Microsoft Community Council. I specialised in ASP.Net and MS SQL Server.
NIMTUG 2004-2008
Powered by Community Server (Non-Commercial Edition), by Telligent Systems