This is somewhat similar to Bug #38331 (and uses the same test case), but since it's not the same error I decided to file a new issue.
Attempting to build and run the following attachment with mono 4.4 throws an exception. However this same test case runs without issue against mono 4.2.3. This is a regression in the 4.4. branch.
### Test Case ###
### Steps ###
1. Download and unzip the attachment
2. Restore NuGet packages and build the project.
3. Use the nunit-console.exe in /packages/ to attempt to run the project.
> mono SomeConsoleTest/packages/NUnit.Runners.lite.220.127.116.1150512/nunit-console.exe SomeConsoleTest/bin/Debug/SomeConsoleTest.dll
### Output ###
> Execution Runtime: mono-4.0
> Unhandled Exception:
> System.InvalidCastException: Specified cast is not valid.
> Server stack trace:
> at (wrapper xdomain-dispatch) NUnit.Core.RemoteTestRunner:Load (object,byte&,byte&)
> Exception rethrown at :
> at (wrapper xdomain-invoke) NUnit.Core.RemoteTestRunner:Load (NUnit.Core.TestPackage)
> at NUnit.Util.TestDomain.Load (NUnit.Core.TestPackage package) <0x28fcc98 + 0x00262> in <filename unknown>:0
### Environment ###
Mono 4.4.0 (mono-4.4.0-branch/3fc068f) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 404000129
Mac OS X 10.11.1
I can repro even on master. Running with mono --debug=casts says "System.InvalidCastException: Unable to cast object of type 'NUnit.Core.TestPackage' to type 'NUnit.Core.TestPackage'".
Update: If I remove everything except SomeConsoleTest.dll, SomeConsoleTest.dll.mdb and nunit.framework.dll from bin/Debug then it works fine.
This suggests to me it's some sort of assembly mismatch between the version that NUnit.Runners.lite brings in and the one from the NUnit nuget.
Actually, I don't see why the runner adds references to the library project at all, the runner should be separate from the actual unit test assembly. The official NUnit.Runners 2.6.4 package for example doesn't have this issue since it doesn't add any references to the unit test assembly itself.
More importantly, I see the exact same behavior on Mono 18.104.22.168 (C6) too. It crashes with InvalidCastException but works when removing the bogus nunit files. Looks like this isn't a bug/regression.
I am also getting this issue (System.InvalidCastException: Specified cast is not valid). If I delete all nunit files except nunit.framework.dll then I am not seeingthis exception. This is the output: https://gist.github.com/saurabh360/ca8db19ae666badbb695f053f2447809