简体   繁体   English

.NET中的SEHException

[英]SEHException in .Net

Setup: 设定:

  • .Net-DLL written in C# 用C#编写的.Net-DLL
  • C++/CLI Wrapper-Dll calling the .Net-DLL 调用.Net-DLL的C ++ / CLI包装器-Dll
  • VS2013, Windows7 32Bit, .Net 4.5.2 VS2013,Windows7 32位,.Net 4.5.2

Assigning a value larger than 2^31-1 to a double in the .Net-DLL will result in an SEHException, everything works fine with smaller values. 为.Net-DLL中的double分配大于2 ^ 31-1的值将导致SEHException,使用较小的值,一切正常。

public void Foo()
{
    double foo = 2147483648d;
        ...
}

does throw an SEHexception when called from the C++/CLI, whereas 从C ++ / CLI调用时确实会引发SEHexception,而

public void Foo()
{
    double foo = 2147483647d;
        ...
}

doesn't. 没有。 Any ideas why this happens and how to avoid the exception? 任何想法为什么会发生这种情况以及如何避免异常?

The DLLs were called from an application which changed the FPU control world. 从改变FPU控制世界的应用程序中调用DLL。 Setting 设置

_control87(_CW_DEFAULT, MCW_EM);

in the C++/CLI Wrapper-DLL before calling into the managed DLL is a quick fix. 在调用托管DLL之前,先在C ++ / CLI Wrapper-DLL中进行修复是一种快速解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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