简体   繁体   中英

Attempted to read or write protected memory from WindowsServer2008 + VS2010 + .NET4.0

My Dev-PC has the followings: WindowsServer2008 + VS2010 + .NET4.0

My troble: {"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}

What have I done: I made one COM component, and made a wrapper for it with C++/CLI, then use C# to visit. In my C# code, the main thread initialize the COM environment, and several children threads to use the resources which have been allocated by the main thread. But if the main thread exit without Join to wait for the end of the children thread, I will encounter the problem which shows "Attempted to read or write protected memory. This is often an indication that other memory is corrupt". This happens even though I use try catch(...) to wrap where the exception was thrown. I really doubt why this happen...

The message indicates that you have a real problem. There are many, many, MANY different things that can cause it - you'll need to look into (all) of your unmanaged code that might be involved.

SUGGESTION:

One not-so-obvious root cause might be FAILING to clean up an allocated resource:

Are you sure you're gracefully freeing everything you've allocated?

PS: Why are you exiting the main thread without Join()?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM