Getting a System.AccessViolationException only during debug

扶醉桌前 提交于 2019-12-24 03:14:22

问题


UPDATE

I've changed the question with my latest findings and simplified as much as possible.

I have the following piece of code

public virtual int DefineAction(bool b, string s, Type1 t1, Type2 t2)
{
    return 1;
}

public ProcessResult Process(bool b, string s, Type1 t1, Type2 t2)
{
   int i = DefineAction(b, s, t1, t2);    
   // more code
}

When I put a breakpoint on the Line var int i= ... and I try to step through it I get an AccessVialoationExeption

UPDATE: If I remove virtual for the function DefineAction no Exeption is thrown.

UPDATE2: If I remove one parameter fromDefineAction for example define it as DefineAction(bool b, string s, Type1 t1) no Exeption is thrown. It's freaking me out now :-(

None of the Assemblies is marked as unsafe. There's nothing running in separate threads.

If I run the program in Visual Studio in Debug mode without breakpoint, the Exeption is not throwing

Any hints or ideas how what's going wrong here?


回答1:


It looks like this VS bug: Weird Access Violation Exception

Reported here: https://connect.microsoft.com/VisualStudio/feedback/details/911564/access-violation-exception-in-vs-hosting-process-when-debugging-application

And assumingly fixed in this .NET release: http://www.microsoft.com/en-us/download/details.aspx?id=42642



来源:https://stackoverflow.com/questions/28233293/getting-a-system-accessviolationexception-only-during-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!