我正在使用System.OutOfMemoryException这行代码:
mutex2 = new Mutex(true, "Name2");
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪:
{"Exception of type 'System.OutOfMemoryException' was thrown."}
at Microsoft.Win32.Win32Native.CreateMutex(SECURITY_ATTRIBUTES lpSecurityAttributes, Boolean initialOwner, String name)
at System.Threading.Mutex.CreateMutexHandle(Boolean initiallyOwned, String name, SECURITY_ATTRIBUTES securityAttribute, SafeWaitHandle& mutexHandle)
at System.Threading.Mutex.MutexTryCodeHelper.MutexTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.Mutex.CreateMutexWithGuaranteedCleanup(Boolean initiallyOwned, String name, Boolean& createdNew, SECURITY_ATTRIBUTES secAttrs)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, Boolean& createdNew, MutexSecurity mutexSecurity)
at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name)
at Foo.FooDefinitions.FooManager.FooForm.FooForm_Load(Object sender, EventArgs e) in c:\tfs\DWS\TRUNK\DEV\FooDefinitions\FooManager\FooForm.cs:line 92
Run Code Online (Sandbox Code Playgroud)
它只会在我使用模仿时发生.没有模拟(在我的普通Windows帐户上运行)它将运行正常.模仿是这样的:
if (!NativeMethods.LogonUser(userName, domainName, password, 2, 0, ref …Run Code Online (Sandbox Code Playgroud)