views:

59

answers:

0

I'm getting an error (see bottom of post) when running NUnit against a production code assembly. The production code assembly has a reference to a third party framework that uses log4net internally (Specifically, this is SimplyAccounting's SDK). The version of log4net that it uses is 1.2.9.0. Outside of this third party framework which we use via the public api from the dll files, log4net is not part of our production code.

While troubleshooting, I eliminated the reference to the production code assembly from the unit test project and added a reference to the SimplyAccounting SDK. When I do this NUnit pukes out the following error. If the third party reference (or the production code reference) is not in the test project then Nunit runs fine. Any workarounds with a potential log4net conflict would be helpful. I'm using NUnit 2.5.2.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at log4net.Layout.LayoutSkeleton.get_Header()
   at log4net.Appender.TextWriterAppender.WriteHeader()
   at log4net.Appender.TextWriterAppender.set_Writer(TextWriter value)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
   at NUnit.Core.Log4NetCapture.SetAppenderTextWriter(TextWriter writer)
   at NUnit.Core.Log4NetCapture.StartCapture()
   at NUnit.Core.TextCapture.set_Enabled(Boolean value)
   at NUnit.Core.RemoteTestRunner.StartTextCapture(EventListener queue)
   at NUnit.Core.RemoteTestRunner.BeginRun(EventListener listener, ITestFilter filter)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NUnit.Core.TestRunner.BeginRun(EventListener listener, ITestFilter filter)
   at NUnit.Core.ProxyTestRunner.BeginRun(EventListener listener, ITestFilter filter)
   at NUnit.Util.TestDomain.BeginRun(EventListener listener, ITestFilter filter)
   at NUnit.Util.TestLoader.RunTests(ITestFilter filter)
   at NUnit.UiKit.TestSuiteTreeView.RunTests(ITest[] tests, Boolean ignoreCategories)
   at NUnit.UiKit.TestSuiteTreeView.RunSelectedTests()
   at NUnit.UiKit.TestTree.RunSelectedTests()
   at NUnit.Gui.NUnitForm.runButton_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)