Skip to main content

Microsoft Silverlight

Answered Question Convert a .NET 2.0 Project to a SilverLight library projectRSS Feed

(0)

phobos7
phobos7

Member

Member

2 points

7 Posts

Convert a .NET 2.0 Project to a SilverLight library project

I'm looking into converting an existing .NET 2.0 project created with Visual Studio into a SilverLight library project. I want to make this an automatable task as we have a lot of code that we would prefer to share between the two projects in addition to avoiding the overhead of manually managing project contents. I've followed the steps outlined in a very useful post on converting a project to a SilverLight project by Neil Mosafi and with a few tweaks I have the project opening up in VS2008 (with SilverLight Beta 1 Development tools). However I still have a problem. I have two questions:

1) Is there any standard way of doing the .NET 2.0 to SilverLight Library project conversion?

2) During my attempted conversion process (I've written a small app which I'm happy to share) I update the "System" reference to "system" but VS2008 still thinks I'm trying to use "System.Uri" from "System". See the following error:

 Error    56    The type 'System.Uri' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.    D:\Research\StreamLinkSilverlight\SilverlightApplication\Page.xaml.cs    27    13    SilverlightApplication

This suggests to me that the project is still referencing the full "System" namespace even though I've updated the project to reference the SilverLight reduced "system" one. Any ideas?

Thanks,

Phil Leggetter
 

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Re: Convert a .NET 2.0 Project to a SilverLight library project

Hello, I think it's easier to update assembly references in Visual Studio than manually modifying the project file. Just remove a reference and add the Silverlight version.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

phobos7
phobos7

Member

Member

2 points

7 Posts

Re: Convert a .NET 2.0 Project to a SilverLight library project

Yi-Lun Luo - MSFT:

Hello, I think it's easier to update assembly references in Visual Studio than manually modifying the project file. Just remove a reference and add the Silverlight version.

 

I'm afraid that manually doing the referencing isn't a viable solution in the long term. As I mentioned in my post I'm looking for a way of sharing project contents between two projects. I was hoping that I could automatically convert a project file - maybe as part of a build step

Another solution would be to share files between the projects using source control. However, whenever a new file is added to the .NET 2.0 project it will also have to be manually added to the SilverLight project. I want to avoid this.

Is there any way of sharing an assembly between a .NET 2.0 project and a SilverLight project or can a SilverLight project only reference another SilverLight assembly? I really need a project that can be used by both SilverLight and a normal .NET 2.0 project.
 

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Answered Question

Re: Re: Convert a .NET 2.0 Project to a SilverLight library project

You can share code, but not assembly. See http://silverlight.net/forums/p/16573/55296.aspx#55296 for more information.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

Neil Mosafi
Neil Mosafi

Member

Member

2 points

1 Posts

Re: Re: Convert a .NET 2.0 Project to a SilverLight library project

Can you try adding the following lines in the PropertyGroups for Debug and Release, and let me know how you get on?

  <NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>

Thanks

Neil 

http://neilmosafi.blogspot.com

surielb
surielb

Member

Member

8 points

5 Posts

Re: Convert a .NET 2.0 Project to a SilverLight library project

You can check out my article at the codeproject:

Converting .NET Assemblies to Silverlight Assemblies
http://www.codeproject.com/KB/silverlight/SLAssemblies.aspx

To Err is human, To Arr is Pirate
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities