C# UWP - Can't add reference to project in sam

2019-04-06 03:05发布

I need to write a UI for an API utility that I need to use. I have created a new Universal Windows App for the UI, added the API utility project to the solution and now need to reference the API utility from the UWP project - but I just get 'Unable to add a reference to project 'XXX'.

If I create a Windows Forms Application or a console project and add that to the solution, I can do the referencing, no probs.

What is it about UWP that I don't understand?

4条回答
叼着烟拽天下
2楼-- · 2019-04-06 03:26

You should create a portable class library for your API utility.

See MSDN: https://msdn.microsoft.com/en-us/library/gg597391(v=vs.110).aspx

查看更多
孤傲高冷的网名
3楼-- · 2019-04-06 03:31

When coding UWP , to build library that can be referenced by a same-solution UI UWP project I need to use a specific library project template (e.g.: by doing Add new Project | Windows | Class Library (Universal Windows)) , that's what worked for me ( I assume you have UWP SDK installed ) so if you have your .dll source maybe you should try to recompile it using that project format. Hope it helps.

查看更多
在下西门庆
4楼-- · 2019-04-06 03:36

When adding the Test Project, instead of going to "Test" and selecting "Unit Test Project (.Net Framework)"… Go to "Windows Universal" and select "Unit Test App (Universal Windows)"

If you select this project, then you will be able to add a reference to your UWP project.

查看更多
仙女界的扛把子
5楼-- · 2019-04-06 03:43

There are two ways to provide reference to c# projects.

Select project -> Right click References -> Add reference
1. via .dll : Browse for Assemblies(.dll files) and select your desired file -> OK
2. via .csproj : Select Projects/Shared Projects from left menu -> browse for the .csproj files (Note: choose file-filter as 'All files' to make them visible) -> OK

查看更多
登录 后发表回答