0xC0020001:字符串绑定无效。- 仅在 WPF 中发生
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11835748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
0xC0020001: The string binding is invalid. - Only occurring in WPF
提问by keynesiancross
First off, I should probably say that I'm probably at a grade 5 level with this stuff... I'm using a C++ add-in in a WPF application. Whenever I try to exit the program, I get this error:
首先,我可能应该说我对这些东西可能处于 5 年级水平...我在 WPF 应用程序中使用 C++ 加载项。每当我尝试退出程序时,都会收到此错误:
Unhandled exception at 0x770d15de in Raptor.exe: 0xC0020001: The string binding is invalid.
Raptor.exe 中 0x770d15de 处的未处理异常:0xC0020001:字符串绑定无效。
I've been using this blog entryto try and figure the problem out, but I'm having no luck. One thing I noticed though, when I use the same C++ addin in a Console application, calling many of the same methods used in the WPF application, the Console exits without a problem.
我一直在使用这个博客条目来尝试解决问题,但我没有运气。但是我注意到的一件事是,当我在控制台应用程序中使用相同的 C++ 插件时,调用 WPF 应用程序中使用的许多相同的方法时,控制台会毫无问题地退出。
I've also gone through the C++ code and cannot find a single static variable declared anywhere. There are static methods though.
我还浏览了 C++ 代码,但找不到在任何地方声明的单个静态变量。虽然有静态方法。
Any help would be much appreciated!
任何帮助将非常感激!
EDIT: I enabled a number of debugging features to see where this breaks. It was breaking the sp_counted_impl.hpp file (Boost) on the last bracket of the following:
编辑:我启用了许多调试功能来查看哪里出错了。它破坏了以下最后一个括号中的 sp_counted_impl.hpp 文件(Boost):
virtual void dispose() // nothrow
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_scalar_destructor_hook( px_, sizeof(X), this );
#endif
boost::checked_delete( px_ );
}
采纳答案by exacerbatedexpert
This occurs with certain DLLs that don't link with native libraries and thus their DllMain does not initialize some needed native subsystem (like CRT or ATL). Sounds like you have a mixed-mode DLL of some sort. One recommended solution is to remove the entry point from the managed DLL: Remove the Entry Point of the Managed DLL
这种情况发生在某些不与本机库链接的 DLL 中,因此它们的 DllMain 不会初始化一些所需的本机子系统(如 CRT 或 ATL)。听起来您有某种混合模式的 DLL。一种推荐的解决方案是从托管 DLL 中删除入口点:删除托管 DLL 的入口点
- Link with /NOENTRY. In Solution Explorer, right-click the project node, click Properties. In the Property Pages dialog box, click Linker, click Command Line, and then add this switch to the Additional Options field.
- Link msvcrt.lib. In the Property Pages dialog box, click Linker, click Input., and then add msvcrt.lib to the Additional Dependencies property.
- Remove nochkclr.obj. On the Input page (same page as in the previous step), remove nochkclr.obj from the Additional Dependencies property.
- Link in the CRT. On the Input page (same page as in the previous step), add __DllMainCRTStartup@12 to the Force Symbol References property.
- 与 /NOENTRY 链接。在解决方案资源管理器中,右键单击项目节点,单击属性。在属性页对话框中,单击链接器,单击命令行,然后将此开关添加到附加选项字段。
- 链接 msvcrt.lib。在“属性页”对话框中,单击链接器,单击输入。,然后将 msvcrt.lib 添加到附加依赖项属性。
- 删除 nochkclr.obj。在 Input 页面(与上一步相同的页面)上,从 Additional Dependencies 属性中删除 nochkclr.obj。
- CRT 中的链接。在 Input 页面(与上一步相同的页面)上,将 __DllMainCRTStartup@12 添加到 Force Symbol References 属性。
More detail can be found here: https://support.microsoft.com/en-us/kb/814472
可以在此处找到更多详细信息:https: //support.microsoft.com/en-us/kb/814472

