1

I have two projects in my Solution. Windows phone Silverlight 8.1 Application and WCF service project. In my WCF project I have some classes that are used in WCF and they also should be used on client side in Windows Phone app. So I want to add a reference to my WCF project. So I right-click on my WP project and select add reference. Then I choose Solution->Projects->and select my wcf project and I get following error:

enter image description here

How can I add a reference to WCF project in my Windows Phone Silverlight application? Because I'm guessing that this is the best way to consume classes from WCF in my WP project?

XardasLord
  • 1,706
  • 2
  • 18
  • 37

1 Answers1

2

The Windows Phone project targets a different framework than the WCF one -- so neither can reference the other. You can either:

  1. Use the auto-generated client proxy that Visual Studio creates when you use "Add Service Reference".
  2. Create a shared project that both WCF and WP projects reference. The shared project can be either a PCL (Portable Class Library), an RIA project -- or just simply two projects that target the separate frameworks, and share the same set of files.

I think #2 using a PCL is preferable, but YMMV.

Community
  • 1
  • 1
McGarnagle
  • 96,448
  • 30
  • 213
  • 255
  • Oh I tried to add shared project as you said - PCL. But neither can be added, WP project nor WCF. The error says: *Portable Library projects can only be reference other Portable Library projects and assemblies.* – XardasLord Dec 19 '14 at 11:55