InvalidCastException while running NUnit tests

cyclotis04's Avatar


20 Mar, 2015 06:20 PM

I'm running into errors using NUnit. I've gotten my test project to build successfully, but the NUnit runner itself encounters a fatal exception, and I'm not sure what it means:

System.InvalidCastException: Return argument has an invalid type.
Server stack trace:
at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg, Type paramType)
at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage msg, Object[] outArgs, Object returnValue)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Core.DomainAgent.CreateRunner(Int32 runnerID)
at NUnit.Util.TestDomain.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Util.RemoteTestAgent.AgentRunner.Load(TestPackage package)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
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.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Util.ProcessRunner.Load(TestPackage package)
at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
at NUnit.ConsoleRunner.Runner.Main(String[] args)
Command exited with code -100

My project is located here:

I'm not sure where the root of the problem lies. The tests run completely and correctly on my local, using VS 2015 CTP and ReSharper 9.


  1. Support Staff 1 Posted by Feodor Fitsner on 20 Mar, 2015 06:43 PM

    Feodor Fitsner's Avatar

    Will take a look.

  2. Support Staff 2 Posted by Feodor Fitsner on 22 Mar, 2015 04:32 AM

    Feodor Fitsner's Avatar

    I see you depend on nunit 2.6.4 however on build workers there are still 2.6.3 - maybe this could be a problem.

    You're already installing 2.6.4 nunit runners into packages directory, so you may try running tests with them with tests auto-discovery disabled.

  3. 3 Posted by cyclotis04 on 23 Mar, 2015 05:38 PM

    cyclotis04's Avatar

    It seems like downgrading to 2.6.3 has fixed it. I also had issues using the latest MSBuild but found that solution as well. I've worked through my process step-by-step of getting NUnit, VS2015, etc., working here:

    Thanks for taking a look!

  4. Support Staff 4 Posted by Feodor Fitsner on 23 Mar, 2015 06:15 PM

    Feodor Fitsner's Avatar

    Sure, thanks for the update!

  5. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:54 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac