开发者

Can' Add window Class library in Silverlight project

Can Any body tell why window class library can't be added in the silverlight project. I have created window class library but can't add that class library in 开发者_JAVA技巧the Silverlight project ?? any idea why is this so ?? I have created silverlight application in version 3.0


Silverlight is a completely different runtime to the full .NET runtime. Also the library API is only a subset. It is possible however, under some circumstances, to go the other way round and link Silverlight projects in full .NET projects.

When you want to reuse code, you have basically three options:

  • Generally create all your basic class libraries as a Silverlight class library project, because it is the framework with the lowest set of features. Throw all references out except for mscorlib.dll, System.dll and System.Core.dll. You can then link such kind of Silverlight library in any full .NET project.

  • You can link individual code files from another project with the "Add as link" feature (Right click project -> Add Existing Item -> Change "Add" Button to "Add as link"). That way you can create a Silverlight project and link individual files from your full .NET project. However that can get tedious if you have a lot of files and you often add/remove files and folders in your source project.

  • To cure this problem, you may check out the Project Linker at http://msdn.microsoft.com/en-us/library/dd458870.aspx ... but I haven't tried it myself yet.


Silverlight projects can only reference Silverlight assemblies in Visual Studio...

Is the assembly you try to reference a Silverlight one ?

Please see this article for further explanation a few tricks to go past the restriction

Hope it helps !


Becuase Silverlight uses a subset of the .NET framework. You may be using resources in your class library that are not available in Silverlight. This is Visual Studios way of enforcing that you only use resources from the Silverlight runtime.

From http://en.wikipedia.org/wiki/Microsoft_Silverlight:

In Silverlight applications, user interfaces are declared in Extensible Application Markup Language (XAML) and programmed using a subset of the .NET Framework. XAML can be used for marking up the vector graphics and animations

Silverlight ships with a lightweight class library which includes features such as extensible controls, XML Web Services, networking components and Language Integrated Query (LINQ) APIs. This class library is a subset of, and is considerably smaller than, .NET Framework's Base Class Library (BCL). Silverlight code runs in a sandbox, thus preventing the invocation of platform APIs

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜