I have a silverlight application which has a class library project in it. th class library is running in .Net framework 4 and the silverlight project is running in silverlight 3. when I want to add a reference in the silverlight proj to the class library I get this message:
“You can’t add a reference to Classlibrary1.dll as it was not built against the silverlight runtime. silverlight project will only work with silverlight asseblies.”
I’ve tried to change the framework the classlibrary1 used to .net framework 3.5, 3, and 2 but it does not help. ( and my silverlight application can only run in silverlight 3)
Apparently Silverlight project will only work with Silverlight asseblies.
CLRs for .NET and Silverlight are different, therefore assemblies are not compatible. These frameworks provide different set of classes, assemblies have different versions, et cetera.
You need to change your Class Library to Silverlight Class Library.
This can either be done by changing project file manually or by creating Silverlight Class Library project and copying the sources in it. If you need the same library for a non-Silverlight project and don’t want to maintain two versions, consider using Add as Link feature of Add Existing Item… dialog to only reference the original sources without copying them. But you’ll need to make sure you only use functionality available on both platforms for both library versions to build.