Build a .NET dll to WP7

2019-02-13 18:44发布

问题:

How can I port a C# dll to WP7?

I have the .dll source code successfully building on desktop but when I try to reference the dll on a WP7 project I get the following error:

Reference cannot be added to c:\path\to\my.dll because it was not built using the Windows Phone runtime. Windows Phone projects will work only with Windows Phone assemblies.

Is there an easy way to build it using Windows Phone runtime?

回答1:

Create a Windows Phone Library project, copy source codes to it and resolve all errors that appears. And than you can reference this dll from Windows Phone project



回答2:

You might also want to take a look at the Portable Class Libraries stuff from Microsoft - http://msdn.microsoft.com/en-us/library/gg597391.aspx - which allows you to compile a DLL up to work for WP7, Silverlight, .Net Framework or XBOX360

I have used it for a .Net WCF service and WP7 projects to share a common DLL.

There are a few things to look out for, in that there are some unsupported assemblies, but in the whole it covers most of what is needed.