小编Rei*_*rDG的帖子

Mutex构造函数上的这个OutOfMemoryException的原因是什么?

我正在使用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)

.net c# impersonation mutex out-of-memory

4
推荐指数
1
解决办法
514
查看次数

标签 统计

.net ×1

c# ×1

impersonation ×1

mutex ×1

out-of-memory ×1