Using the --runtime option should bypass the problem.
However, what you are doing is intended to work. Specifically, nunit-console.exe
should run under the 2.0 CLR and then launch an nunit-agent.exe process under
the 4.0 CLR. You can force this behavior with the -framework option
but that should
not be necessary provided that the test assembly has been created targetting
.NET/Mono 4.0 and also provided that the compiler has put this information into
the assembly in the first place.
As you can see, there are several points where this could go wrong and it would
be helpful to figure out just why it's happening. I'm copying this reply to the
nunit-discuss list in case others have run into the same problem.
Charlie
On Thu, Oct 20, 2011 at 8:24 AM, Dale Ragan <dale....@moncai.com> wrote:
> Hey Charlie,
>
> I just want to understand NUnit's behavior a little better and run a
> scenario by you. I have a Test dll that is compiled for .NET/Mono 4.0 and
> I'm using the latest NUnit 2.5.10 from the website. I'm encountering a
> TypeLoadException when running the test under Mono with the following
> command:
>
> mono --debug nunit-console.exe -nodots /path/to/tests.dll
>
> I think I know what is causing the issue, more than likely the runner isn't
> using the 4.0 runtime to run the tests, because NUnit is still outputting
> that it's using the 2.0 CLR. My assumption, based on this page[1], was that
> NUnit would run the test under the 4.0 runtime automatically for you or do
> you still need to pass the framework option? Also, does it help to force
> Mono to run under the 4.0 runtime by using the --runtime option, since NUnit
> is compiled to use 2.0 version of the CLR? Here's what I plan on trying
> tonight, but I wanted to understand the underlying behavior also and whether
> I need to provide the framework option.
>
> mono --debug --runtime=v4.0.30319 nunit-console.exe -nodots
> /path/to/tests.dll
>
> Thanks,
>
> Dale
>
> [1]: http://nunit.org/index.php?p=runtimeSelection&r=2.5.10
>
Dale
Dale Ragan
October 20, 2011 1:55 PM
Thanks Charlie, that's what I thought. I will give it a test again tonight and I will let you know if it works with the --runtime or with the -framework option. If they do, I'll give you the test case to figure out why it's not picking up the correct CLR version from the assembly.
Dale
Charlie Poole
October 20, 2011 12:20 PM
Dale Ragan
October 20, 2011 9:45 PM
The only way I can get the test to run without throwing a TypeLoadException is by providing --runtime=v4.0 to Mono.
--
You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
To post to this group, send email to nunit-...@googlegroups.com.
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nunit-discuss?hl=en.
I haven't tried any other way.
Charlie
Charlie Poole
Thursday, October 20, 2011 11:30 PM
If it works with a simple (i.e. 2 + 2 == 4) test, that would mean
there's something
about this particular test. Could the library you're using require x86
mode, for example?
Charlie
Dale Ragan
Thursday, October 20, 2011 11:05 PM
I haven't tried any other way.
Charlie Poole
Thursday, October 20, 2011 10:36 PM
Hi Dale,
Does the problem only show up with this particular test present or can you make it happen with a simple test that doesn't pull in any other references?
Charlie
--
You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
To post to this group, send email to nunit-...@googlegroups.com.
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nunit-discuss?hl=en.
Dale Ragan
Thursday, October 20, 2011 1:55 PM
Thanks Charlie, that's what I thought. I will give it a test again tonight and I will let you know if it works with the --runtime or with the -framework option. If they do, I'll give you the test case to figure out why it's not picking up the correct CLR version from the assembly.
Dale
Charlie Poole
Thursday, October 20, 2011 12:20 PM
I tried with nunit-console-x86.exe with the original command without the
--runtime option and same results, TypeLoadException. Anything else
you'd like me to try?
Charlie