通过项目添加对windows phone类库的引用将构建;直接添加dll失败 [英] Adding reference to windows phone class library via project will build; adding the dlls directly fails

查看:59
本文介绍了通过项目添加对windows phone类库的引用将构建;直接添加dll失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不太确定如何表述标题,因为我对这个问题很困惑,欢迎编辑或建议澄清...

I wasn't quite sure how to word the title as I'm very confused about this problem, edits or suggestions to clarify are welcome...

无论如何,问题是我有一个 Windows Phone 8.1 (RT) 应用程序,我正在尝试使用添加对类库的引用,以便我可以在该项目中使用代码和 XAML 视图.

Anyway, the problem is that I have a Windows Phone 8.1 (RT) application, and I'm attempting to use add a reference to a class library so that I can make use of code and XAML views in that project.

如果我将整个类库项目添加到我的 Visual Studio 解决方案中,然后在我的应用中添加对该项目的引用,则一切正常.

If I add the entire class library project to my visual studio solution, and then add a reference to that project in my app, everything works fine.

但是,如果我删除引用和库项目,而是添加对类库项目的相同 DLL 文件的引用,我的应用程序将不再构建.

However, if I remove the reference and library project, and instead add a reference to the same DLL files of the class library project, my application will no longer build.

错误信息是这样的:

有效载荷文件'C:\Users\Me\Desktop\MyProject\MyClassLibrary\bin\Debug\ MyClassLibrary\MyPage.xbf'不存在.

Payload file 'C:\Users\Me\Desktop\MyProject\MyClassLibrary\bin\Debug\ MyClassLibrary\MyPage.xbf' does not exist.

那个粗体 MyClassLibrary 是一个无关的文件夹定义,我无法识别其来源.如果我通过解决方案将类库添加为引用,即使该文件夹不存在,它也能很好地构建.

that bold MyClassLibrary is an extraneous folder definition whose origin I cannot identify. If I add the class library as a reference via the solution, it builds just fine, even though that folder doesn't exist.

但是当我仅添加对相同 DLL 文件的引用时,它开始在该文件夹中查找.如果我手动创建该文件夹并将所有内容复制到其中,我可以像以前一样构建和运行,但这似乎是一个黑客,因为如果我添加项目引用,它可以在没有此解决方法的情况下正常工作......

but when I add the reference to the same DLL files only, it starts looking in that folder. if I create that folder manually and copy everything into it, I can build and run like before, but that seems like a hack, as it works fine without this workaround if I add the project reference instead...

为什么要这样做?根据构建的输出,它似乎是此错误的结果:

Why is it doing this? according to the output of the build it appears to be a result of this error:

1>C:\程序文件(x86)\MSBuild\Microsoft\VisualStudio\v12.0\AppxPackage\Microsoft.AppXPackage.Targets(1496,9):错误 APPX0702:有效负载文件'C:\Users\Me\Desktop\MyProject\MyClassLibrary\bin\Debug\MyClassLibrary\MyPage.xbf'不存在.

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\AppxPackage\Microsoft.AppXPackage.Targets(1496,9): error APPX0702: Payload file 'C:\Users\Me\Desktop\MyProject\MyClassLibrary\bin\Debug\MyClassLibrary\MyPage.xbf' does not exist.

但是为什么当我直接添加对 dlls 文件的引用时它会附加该文件夹,它来自哪里以及如何阻止它这样做?

but why does it append that folder when I add the reference to the dlls files directly, where is it coming from and how can I stop it from doing that?

推荐答案

这个很棘手.事实上,当您构建应用商店应用程序时,(电话或 Windows 8)您不能仅通过引用 dll 来添加包含 xaml 的库.它只是不起作用并显示此类错误.您不能像在 Silverlight 中那样将 xaml 打包到 WinRT 库中.

This one is tricky. In fact when you build Store apps, (Phone or Windows 8) you cannot add libraries that contains xaml just by referencing the dll. It just won't work and display this kind of errors. You cannot package xaml into your WinRT librairies as you would in Silverlight.

请阅读这些链接

DLL 上的嵌入式 Xaml 页面

http://timheuer.com/blog/archive/2012/03/07/creating-custom-controls-for-metro-style-apps.aspx

这篇关于通过项目添加对windows phone类库的引用将构建;直接添加dll失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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