我有一个需要在64位进程中运行的程序集,但我不能让它在nunit runner中运行。
我创建了一个测试代码,非常简单,只需在main函数和nunit测试函数中打印出指针大小:
using System;
using NUnit.Framework;
namespace PtrSize
{
class MainClass
{
[Test]
public static void Test()
{
Console.WriteLine ("IntPtr.Size : {0}", IntPtr.Size);
Console.WriteLine ("Environment.Is64BitProcess : {0}", Environment.Is64BitProcess);
}
public static void Main (string[] args)
{
Console.WriteLine ("IntPtr.Size : {0}", IntPtr.Size);
Console.WriteLine ("Environment.Is64BitProcess : {0}", Environment.Is64BitProcess);
}
}
}
然后我做了以下测试:
首先我确认单声道是64位内置
Build-Agent-Mac-01s-iMac:Debug BA-Mac-01$ ~/sandbox/mono64/bin/mono --version
Mono JIT compiler version 3.10.0 (tarball Thu Jan 8 09:23:28 CET 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
然后我使用这个单声道来运行我的测试程序,它是64位进程:
Build-Agent-Mac-01s-iMac:Debug BA-Mac-01$ ~/sandbox/mono64/bin/mono PtrSize.exe
IntPtr.Size : 8
Environment.Is64BitProcess : True
然后我使用nunit test runner来运行它,并且它始终处于32位模式,我也尝试了nunit-console-x86.exe,但仍然没有帮助。
Build-Agent-Mac-01s-iMac:Debug BA-Mac-01$ ~/sandbox/mono64/bin/mono ~/Downloads/NUnit-2.6.4/bin/nunit-console.exe PtrSize.exe
NUnit-Console version 2.6.4.14350
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.
Runtime Environment -
OS Version: Unix 14.5.0.0
CLR Version: 2.0.50727.1433 ( Mono 3.5 ( 3.10.0 (tarball Thu Jan 8 09:23:28 CET 2015) ) )
ProcessModel: Default DomainUsage: Single
Execution Runtime: mono-3.5
.IntPtr.Size : 4
Environment.Is64BitProcess : False
Tests run: 1, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.0132951 seconds
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
任何机构都对此问题有所了解?
答案 0 :(得分:2)
从Mono 4.2.1开始,安装程序包含64位版本的mono。不幸的是,nunit-console命令仍然以32位运行。
要将nunit-console作为64位运行,您仍需要使用mono64命令:
mono64 /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/nunit-console.exe <path to dll>