Well, in VS2005 you can create a class library which will build against the Silverlight runtime, but it's a little work.
- Create a Class Library/
- Remove all references from it.
- Right-click on the Project and pick Properties.
- On the Build tab, click Advanced and check 'Do not reference mscorlib.dll'
- Manually add references to mscorlib, agclr, System,System.Core, System.Silverlight, and System.Xml.Core from the Silverlight install folder (\Program Files\Microsoft Silverlight\)
At this point your build outputs should be Silverlight consumable binaries. It looks
like the equivalent command line call to csc.exe (the C# compiler) should include the references to the mentioned binaries and the /nostdlib option but may require others as well.
The above mentioned solution could not be implemented on a VB project because there was no way I could tell the vb compiler to not reference mscorlib.dll as the compiler requires the Microsoft.VisualBasic.dll which refers to system.dll and finally we get a reference to mscorlib.dll. Thus I had to find a workaround for this…
The idea was to trick visual studio and use the silverlight framework instead of the normal .net 2.0. So I created a class library project based on the .NET Compact Framework 2.0 for Windows CE 5.0. Thus I got the compiler looking for the framework in the following path: "C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\CompactFramework\2.0\v2.0\WindowsCE\"
Since I am not currently developing any windows CE application I simply replaced the contents of that path with the ones from the silverlight framework (located at "C:\Program Files\Microsoft Silverlight\").
So, we have tricked the compiler to not use the regular .net framework. From now on the things are quite straight forward.
- Create a Class Library.
- Remove all references from it.
- Manually add references to mscorlib, agclr, System, System.Core, System.Silverlight, and System.Xml.Core from the Silverlight install folder (\Program Files\Microsoft Silverlight\)
Done. Create your xaml, html and js files and you are ready to experience the silverlight experience through visual studio 2005 and vb.net :)
Bryant Likes offers a c# example of the Hello world application on his blog http://blogs.sqlxml.org/bryantlikes/archive/2007/05/02/silverlight-hello-world-in-c-from-vs-2005.aspx .
Thus I converted the above example in to the following vb.net hello world example: