sta*_*oat 3 c++-cx windows-phone-8
我在WP8应用程序中有一个C++运行时组件,如果我更改命名空间名称,每当我尝试在该命名空间中实例化一个类时,我都会抛出一个"TargetInvocation"异常.
例如,如果我创建默认的C++ Windows运行时组件,标题如下所示:
#pragma once
namespace CppComponent1
{
public ref class WindowsPhoneRuntimeComponent sealed
{
public:
WindowsPhoneRuntimeComponent();
};
}
Run Code Online (Sandbox Code Playgroud)
如果我更改CppComponent1为CppComponent2.h和.cpp,然后尝试WindowsPhoneRuntimeComponent在我的C#代码中实例化一个对象,我会收到以下错误:
A first chance exception of type 'System.TypeLoadException' occurred in Unknown Module.
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in Microsoft.Phone.ni.dll
Run Code Online (Sandbox Code Playgroud)
如何在WP8应用程序中更改本机模块的命名空间?谢谢!
声明组件的Windows元数据(WinMD)文件的名称必须是声明公共类型的命名空间的前缀.(在另一个问题的答案中,我提供了一个稍微更详细的命名空间规则说明.)
如果将命名空间重命名CppComponent1为CppComponent2,则还需要将构建生成的WinMD文件重命名CppComponent1.winmd为CppComponent2.winmd.
| 归档时间: |
|
| 查看次数: |
1766 次 |
| 最近记录: |