Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010: Warning on add project reference to Silverlight project from .NET project

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.

like image 797
nlawalker Avatar asked May 07 '10 23:05

nlawalker


2 Answers

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.

like image 169
nlawalker Avatar answered Nov 17 '22 16:11

nlawalker


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.

like image 3
amurra Avatar answered Nov 17 '22 15:11

amurra