16

In VS2010, Silverlight 4, .NET 4, I've got a WCF service and a Silverlight app, and Silverlight is accessing the class not with Add Service Reference but by sharing the contract. Naturally, this means I have the contract in a Silverlight class library, and the service has a project reference to that library.

Strangely, this results in a /!\ icon on the reference, and a warning:

The project 'SilverlightClassLibrary1' cannot be referenced. The referenced project is targeted to a different framework family (Silverlight)

However, the reference works fine (I can use the interface in my Silverlight app) and builds fine.

Is this a bug? My guess is yes, since the warning is lying and also goes away if you add an assembly reference instead of a project reference. I filed a bug and there's more info here as well.

nlawalker
  • 6,364
  • 6
  • 29
  • 46
  • Note that it is only a *warning*. I've seen similar - in fact, that is why I didn't expand the "references" in the `SerializerGenerator` picture, here http://marcgravell.blogspot.com/2010/04/walkthrough-protobuf-net-on-phone-7.html (the `MyDto` project is, like yours, Silverlight). Good question, though. Good spot re the difference between project/dll reference. I'll give that a go for what I'm doing ;-p – Marc Gravell May 07 '10 at 23:19
  • Interesting. Does it complain if, rather than adding a DLL reference you include the Contracts into a Silverlight DLL by linking the files? – Doobi May 08 '10 at 14:51
  • No, it doesn't complain, since you're literally copying the code into another assembly. – nlawalker May 26 '10 at 22:55

2 Answers2

15

Microsoft responded to the bug I posted. The warning is intended to exist and intended to be a warning and not an error, although I would argue that the text is bad. The reason is that referencing a Silverlight project will result in runtime failures if Silverlight isn't installed properly on the machine. There is currently no way to suppress the warning.

nlawalker
  • 6,364
  • 6
  • 29
  • 46
  • 2
    I'm a bit confused - does this mean Silverlight has to be installed on the server hosting my wcf service? Thanks for providing the useful info – tomfumb Aug 10 '11 at 23:59
  • 1
    Hm, the URL is not working anymore. Do you, by any chance, remember its name, so I can try to find it again? I tried searching for ["The referenced project is targeted to a different framework family (Silverlight)"](https://connect.microsoft.com/SearchResultsLive.aspx?SearchQuery=different%2bframework%2bfamily%2b(Silverlight)) in Microsoft Connect, but nothing popped out. – Borislav Ivanov Oct 22 '12 at 13:13
3

If you want the warning to disappear you can add the dll directly by using the "Add Reference"-->"Browse" instead of adding the project via "Add Reference"-->"Projects".

This was a very annoying issue for us as well and this was the only workaround we found that worked.

amurra
  • 15,221
  • 4
  • 70
  • 87
  • This is not a good solution as it does not address Release vs Debug builds. A clean workspace build on the wrong type will fail as the DLL won't exist unless you statically checkin DLLs into your source control or you set the output directories for Debug/Release to the same folder for that project dependency. Even then particularly for multi-threaded builds, the solution will be missing the build project dependency for calculating the correct build orders of projects. – Shiv Aug 06 '17 at 22:06