This morning I got this exception when running my build on the build server.

Command Line: “f:Source TexdatabasesProjectsTDB2007.Dal.DataAccessLayer.TestbinDebugTDB2007.Dal.DataAccessLayer.Test.dll” /config=“f:Visual Studio 2005ProjectsTDB2007ProjectsMenubinDebugDataAccessLayer.dll.config” /nologo<br /> Unhandled Exception:<br /> System.IO.FileLoadException: Could not load file or assembly ‘nunit.core, Version=2.4.6.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77’ or one of its dependencies. Exception from HRESULT: 0x80131902<br /> File name: ‘nunit.core, Version=2.4.6.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77’ —> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize —> System.Configuration.ConfigurationErrorsException: ‘NUnitCategories.Categories.nHibernate’ is an unexpected token. The expected token is ‘“’ or “‘. Line 31, position 18. (f:Source TexdatabasesProjectsTDB2007.Dal.DataAccessLayer.TestbinDebugTDB2007.Dal.DataAccessLayer.Test.dll.config line 31) —> System.Xml.XmlException: ‘NUnitCategories.Categories.nHibernate’ is an unexpected token. The expected token is ‘“’ or “‘. Line 31, position 18.<br /> at System.Xml.XmlTextReaderImpl.Throw(Exception e)<br /> at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)<br /> at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(String expectedToken1, String expectedToken2)<br /> at System.Xml.XmlTextReaderImpl.ParseAttributes()<br /> at System.Xml.XmlTextReaderImpl.ParseElement()<br /> at System.Xml.XmlTextReaderImpl.ParseElementContent()<br /> at System.Xml.XmlTextReaderImpl.Read()<br /> at System.Xml.XmlTextReader.Read()<br /> at System.Xml.XmlTextReaderImpl.Skip()<br /> at System.Xml.XmlTextReader.Skip()<br /> at System.Configuration.XmlUtil.StrictSkipToNextElement(ExceptionAction action)<br /> at System.Configuration.BaseConfigurationRecord.ScanSectionsRecursive(XmlUtil xmlUtil, String parentConfigKey, Boolean inLocation, String locationSubPath, OverrideModeSetting overrideMode, Boolean skipInChildApps)<br /> at System.Configuration.BaseConfigurationRecord.ScanSections(XmlUtil xmlUtil)<br /> at System.Configuration.BaseConfigurationRecord.InitConfigFromFile()<br /> — End of inner exception stack trace —<br /> at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)<br /> at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)<br /> at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()<br /> at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)<br /> — End of inner exception stack trace —<br /> at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)<br /> at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)<br /> at System.Configuration.ConfigurationManager.GetSection(String sectionName)<br /> at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)<br /> at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()<br /> at System.Diagnostics.DiagnosticsConfiguration.Initialize()<br /> at System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()<br /> at System.Diagnostics.TraceInternal.InitializeSettings()<br /> at System.Diagnostics.TraceInternal.WriteLine(String message, String category)<br /> at System.Diagnostics.Trace.WriteLine(String message, String category)<br /> at NUnit.Core.AssemblyResolver.CurrentDomain_AssemblyResolve(Object sender, ResolveEventArgs args)<br /> at System.AppDomain.OnAssemblyResolveEvent(String assemblyFullName)<br /> at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)<br /> at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)<br /> at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)<br /> at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)<br /> at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)<br /> at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)<br /> at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)<br /> at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)<br /> at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)<br /> at NUnit.Util.TestDomain.MakeRemoteTestRunner(AppDomain runnerDomain)<br /> at NUnit.Util.TestDomain.Load(TestPackage package)<br /> at NUnit.ConsoleRunner.ConsoleUi.MakeRunnerFromCommandLine(ConsoleOptions options)<br /> at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)<br /> at NUnit.ConsoleRunner.Runner.Main(String[] args)<br />

I was focussing on this ‘NUnitCategories.Categories.nHibernate’ is an unexpected token. The expected token is ‘”‘ or ”’. which to me meant that the error was somewhere in the CategoryAttribute somewhere Like in this case <Category(Categories.nHibernate)> _.

But it wasn’t when changing the categories to a more refacotr frienldy version, like I mentioned before, I did a wrong find and replace. I namely replace “nHibernate” with NUnitCategories.Categories.nHibernate and I also seem to have this little nHibernate word in the app.config file I use in this project.

Which now was this

&lt;logger name=NUnitCategories.Categories.nHibernate&gt;
      &lt;level value="Warn" /&gt;
      &lt;appender-ref ref="rollingFile"/&gt;
    &lt;/logger&gt;```
Instead of this

<logger name=“NHibernate”> <level value=“Warn” /> <appender-ref ref=“rollingFile”/> </logger>``` Of course that was the real cause of that exception.

The weird thing is that the resharper testrunner just doesn’t run the tests but doesn’t give an error either (no where visible anyway) but the Tesdriven.Net does give a suitable error.

—— Test started: Assembly: TDB2007.Dal.DataAccessLayer.Test.dll ——

Check your ‘App.config’ file.

NUnitCategories.Categories.nHibernate is een onverwacht token. Het verwachte token is ” of ‘. Regel 31, positie 18.

So it’s always good to have more then one testrunner to get the correct message so you can solve it quickly.