错误我从未见过!未处理的类型' System.AccessViolationException'发生在mscorlib.dll中

时间:2015-09-13 05:54:30

标签: c# kernel32

嗯,我之前从未见过的错误,是否有人知道为什么会这样?

"未处理的类型' System.AccessViolationException'发生在mscorlib.dll中 "

堆栈跟踪

    StackTrace  "   at System.String..ctor(SByte* value)\r\n   at System.StubHelpers.CSTRMarshaler.ConvertToManaged(IntPtr cstr)\r\n   at SharpTUI.dlls.Kernal32.GetConsoleTitle(String& lpConsoleTitle, UInt32 size)\r\n   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)\r\n   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.ThreadHelper.ThreadStart()"   string

CODE:

        uint x = Kernal32.GetConsoleTitle(out windowTitle, 9999);
        IntPtr ip = User32.FindWindow(null, windowTitle);
        User32.GetWindowRect(ip, ref windowRect);

        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern uint GetConsoleTitle(
           out string lpConsoleTitle,
           uint size);

0 个答案:

没有答案