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:
2 comments:
After posting the same article in Greek in www.dotnetzone.gr (thread http://www.dotnetzone.gr/cs/forums/thread/32919.aspx), kelman contributed the following comment:
The Vb Runtime is required for two reasons. First of all it’s the backward compatibility with vb 6 (MsgBox, Left, Right, etc) and moreover it contains a lot of helper functions which are not supported by IL and without then the code would not compile.
In VS 2005 it is impossible to not reference them. But, in the early beta 2 of vs 2008 there will be a compiler switch (mainly /vbruntime) which will allow compilation without the default reference to Microsoft.VisualBasic.DLL. This switch can be used only through command-line since the UI does not support it yet.
Cheers kelman for the contribution.
Silverlight facilitates the WPF movement design. This is not only time centered but also allows you determine the begin and end circumstances and allows you get there.
Post a Comment