Building Windows Presentation Foundation applications in Visual Basic 2008

Setting Option Strict Off can be a very useful thing in Visual Basic but having project template depend on it being this way certainly isn’t a good thing [:(]

Unfortunately this is the case with the WPF project template for VB and the result could be a compile error in a new project depending on your default setting of Option Strict. Not a big deal as the error is easy to correct but still a bit of a nuisance. Fortunately the error isn’t hard to correct and requires only a single code change. Find the line of code with the error, this should be:

Return Global.System.Windows.Application.Current

And add a type cast to is like this:

Return CType(Global.System.Windows.Application.Current, Application)

And you should be ready to go. The best place to make this change is in the project template so you only have to do this once. The steps required, and more information, can be found here http://support.microsoft.com/kb/945756

Enjoy!

6 thoughts on “Building Windows Presentation Foundation applications in Visual Basic 2008

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>