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 17 May 2006 11:18 by Damien McGivern
Filed under:

Comments

# re: Could not load file or assembly nunit.core

04 July 2006 22:00 by Fritz Schenk
Very clear

# re: Could not load file or assembly nunit.core

07 July 2006 15:43 by Yaroslav Mygach
Thanks a lot it really helps. I've got same issue today. After I fixed test application config file nunit start working properly.

# re: Could not load file or assembly nunit.core

10 July 2006 12:56 by Marcus Widerberg
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.

# re: Could not load file or assembly nunit.core

10 July 2006 22:57 by dan b
you hit my problem nail on the head.  nice post.  thanks

# re: Could not load file or assembly nunit.core

14 July 2006 15:04 by Pascal G.
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....

# re: Could not load file or assembly nunit.core

18 July 2006 09:15 by Janssens Luc
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!!!!

# re: Could not load file or assembly nunit.core

03 August 2006 12:48 by config dummy
AGGHH excactly the same problem!!! cost me 2 hours!

Tanxxxx!

# re: Could not load file or assembly nunit.core

04 August 2006 03:27 by Deasy
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.

# re: Could not load file or assembly nunit.core

07 September 2006 06:33 by Rohit
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

# re: Could not load file or assembly nunit.core

02 October 2006 20:37 by Bryan W. Young
Thanks for the tip.  Once I checked my app.config file, I found the problem.

# re: Could not load file or assembly nunit.core

25 October 2006 15:38 by Paul Lockwood
Thanks, this post led me straight to our issue.

# re: Could not load file or assembly nunit.core

27 October 2006 08:44 by Bgmate
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

# re: Could not load file or assembly nunit.core

08 January 2007 09:26 by Jagdish
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

# re: Could not load file or assembly nunit.core

24 August 2007 23:59 by Shehzad Sheikh

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 ..:)

# re: Could not load file or assembly nunit.core

01 October 2007 23:30 by Judah

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?

# re: Could not load file or assembly nunit.core

02 October 2007 10:08 by Damien McGivern

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.

# re: Could not load file or assembly nunit.core

23 May 2008 20:15 by Yusef

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.

# re: Could not load file or assembly nunit.core

26 July 2008 02:35 by Arvind

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

# re: Could not load file or assembly nunit.core

04 December 2008 10:44 by Shahidul

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.

Leave a Comment

(required) 
(required) 
(optional)
(required)