WP运行时组件-类型加载异常? [英] WP Runtime Component - Type load exception?

查看:48
本文介绍了WP运行时组件-类型加载异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows Phone 8解决方案,其中包含2个项目:

I have a Windows Phone 8 solution with 2 projects:

  • "Hello",一个简单的库项目->生成 Hello.dll .
  • "HelloNativeRT",一个带有C ++文件的WP运行时组件->生成 HelloNativeRT.dll HelloNativeRT.winmd

在此解决方案中,"Hello"库引用了WP Runtime Component,因此调用类似于...

In this solution, the "Hello" library references the WP Runtime Component, so calls like...

HelloNativeRT.SampleNamespace test = new HelloNativeRT.SampleNamespace();

...在此图书馆项目中工作正常.

...work fine in this library project.

但是,我想在Windows Phone 8应用中使用这两个库,但是不添加对项目的引用,因为我需要将编译后的库发送到客户.

However, I want to use these two libraries in a Windows Phone 8 app, but without adding references to the projects, since I need to ship the compiled libraries to clients.

  • 我引用了项目中的 Hello.dll 文件以及 HelloNativeRT.winmd 文件.
  • 当我以调试模式启动应用程序并转到 HelloNativeRT.SampleNamespace test = new HelloNative ... 行时,它崩溃并显示"TypeLoadException",就像它无法加载本机模块一样.
  • I referenced the Hello.dll file in the project, as well as the HelloNativeRT.winmd file.
  • When I launch the application in debug mode, and goes to the line HelloNativeRT.SampleNamespace test = new HelloNative... it crashes and says "TypeLoadException", like it cannot load the native module.

我想我需要以某种方式包含 HelloNativeRT.dll 文件,因为我猜它包含本机(编译)代码,因为winmd文件可能只嵌入了C ++/CX代码.

I suppose I need to include the HelloNativeRT.dll file in a way or another, since I guess it contains the native (compiled) code, as the winmd file may only embed the C++/CX code.

如何设置我的项目以包含此DLL?

我试图将其放在WP8项目的根目录中,以进行引用,然后将其嵌入...没有运气.

I tried to put it at the root of the WP8 project, to reference it, to embed it... with no luck.

推荐答案

在我的情况下,原因很简单:从WinRT组件生成的.winmd文件和.dll文件必须具有相同的名称(例如:testRT.dll和testRT.winmd).

The reason was quite simple in my case: the .winmd file and the .dll file generated from the WinRT Component must have THE SAME NAME (e.g: testRT.dll and testRT.winmd).

然后:

  • 将.winmd medata文件添加为项目中的引用.
  • 检查.winmd/dll文件是否在同一文件夹中以正确加载.

这篇关于WP运行时组件-类型加载异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆