Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
390 views
in Technique[技术] by (71.8m points)

interop - AccessViolationException outside Visual Studio?

I'm developing a small C# winforms application that consumes an unmanaged C++ library. I have no access to the code of this library.

If I'm in Visual Studio and I runt my application, do my calls to the library everything is working find. Once I run CTRL + F5 I get an AccessViolationException. I did some testing, created another winforms application in .NET 2.0 (others were in .NET 4.0) and there I don't receive the AccessViolationException. So I thought i'd create a .net 2.0 class library in my .net 4.0 solution and consume that class lib. This didn't help, still I had the AccessViolationException.

Tried setting allow unsafe code, optimize code on and off but that didn't help. Why am I getting the AccessViolationException once I'm out of debug mode?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I just stumbled upon the same issue. To reproduce the problem in the debugger, I had to go to:

ToolsOptions DebuggingGeneral

and disable: Suppress JIT optimization on module load (managed only).

Of course the problem would only appear for a optimized code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...