R – Compiling Silverlight runtime question

silverlightsilverlight-2.0silverlight-3.0

I have created a Silverlight project which also contains a Web project.

I have a few class files in my web project which use System.Windows.Point and System.Windows.Size data types and I am getting compile errors when I try to pass either of these types in a List like List<Point> in the Silverlight project. If I try without the List<> I still get the Point data type error.

I reviewed information about compiling Silverlight assemblies from David Betz site I found a tool to help me used the first of the two approaches he discusses and have successfully compiled the runtime and referenced it in my Silverlight project.

Here are the errors:

  • The type 'System.Windows.Point' is
    defined in an assembly that is not
    referenced. You must add a reference
    to assembly 'WindowsBase,
    Version=3.0.0.0, Culture=neutral,
    PublicKeyToken=31bf3856ad364e35'. C:\Documents
    and Settings\Gary\My Documents\Visual
    Studio
    2008\Projects\GEP.Reports.Spatial\GEP.Reports.Spatial\MainPage.xaml.cs
  • cannot convert from
    'System.Collections.Generic.List
    [c:\Program Files\Reference
    Assemblies\Microsoft\Framework\Silverlight\v3.0\mscorlib.dll]'
    to
    'System.Collections.Generic.List
    [c:\Program Files\Reference
    Assemblies\Microsoft\Framework\Silverlight\v3.0\mscorlib.dll]

What step am I missing in order to get these types added to my Silverlight runtime.

Thanks for any help.

Gary

Best Answer

For simple types like Point and Size you are better off rolling your own structs/classes rather than trying to find ways of referencing non-Silverlight assemblies. In addition you don't really want something like the System.Windows assembly being included in your .xap for the sake of something like the Point struct.

Related Topic