How do you reference a C# class library from a Win

2020-04-05 06:04发布

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

1条回答
贼婆χ
2楼-- · 2020-04-05 06:45

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

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.

查看更多
登录 后发表回答