如何从 Win8 Javascript Metro 应用程序中引用 C# 类库?

How do you reference a C# class library from a Win8 Javascript metro application?(如何从 Win8 Javascript Metro 应用程序中引用 C# 类库?)

本文介绍了如何从 Win8 Javascript Metro 应用程序中引用 C# 类库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试标准方式时,它抱怨引用不受支持,我似乎无法使用我的任何类.

When I try the standard way it complains of an unsupported reference and I can't seem to use any of my classes.

推荐答案

您需要通过Visual C#"->Windows Metro Style"->类库"模板创建类库来创建 Windows 运行时组件.然后在该类库项目的属性中,您需要将输出类型标记为WinMD 文件"

You need to create a Windows Runtime component by creating a class library from the "Visual C#" -> "Windows Metro Style" -> "Class Library" template. Then in the properties for that class library project you need to mark the output type as "WinMD File"

可以在这里找到更好的说明:

Better instructions can be found here:

http://msdn.microsoft.com/en-us/library/windows/apps/hh779077(v=vs.110).aspx

这在文档中没有说明,可能只是 Windows 8 Consumer Preview 和 Visual Studio 11 Beta 的一个错误,但请确保不要在您引用的项目名称中包含句点.例如,我正在开发一个 Car 应用程序,所以我制作了一个名为Car.Business"的程序集.每当我尝试引用它时,应用程序总是会崩溃并出现空白启动屏幕.另一方面,如果我只是使用Business"作为程序集的名称,那么该应用程序可以正常工作.

This isn't stated in the documentation and is probably just a bug with the Windows 8 Consumer Preview and the Visual Studio 11 Beta but be sure not to include a period in the name of the project you're referencing. For instance, I was working on a Car application so I made an assembly named "Car.Business". The application would always crash with a blank startup screen whenever I tried to reference this. If on the other hand I just used "Business" as the name of the assembly then the application would work fine.

这篇关于如何从 Win8 Javascript Metro 应用程序中引用 C# 类库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何从 Win8 Javascript Metro 应用程序中引用 C# 类库?

基础教程推荐