Thu, November 22, 2007, 02:56 AM under
Orcas |
VisualStudio
In my global Visual Studio project settings for VB projects I always have
Option Strict set to On, so any new VB project I create has this setting without me having to do it manually every time.
If you do the same as me above, then when you create a Visual Basic WPF project in
Visual Studio 2008 RTM, you may get a compilation error before you have a chance to write any code:
Option Strict On disallows implicit conversions from 'System.Windows.Application' to 'WpfApplication1.Application'.Double click on the compilation error in your Error List window and it will open the offending file:
MyWpfExtension.vb
and specifically the ReadOnly Application property that returns an object of type Application. The problem is that the single return statement does not perform a cast:
Return Global.System.Windows.Application.Current
So you have to change it (or in fact choose the cool auto correction option to change it for you) to:
Return CType(Global.System.Windows.Application.Current, Application)
WARNING: The following step has the potential to irrevocably cripple your machine so take backups if you decide to proceed!
If you want to change this globally on your machine and are willing to take your life into your own hands and venture into unsupported territory then you can edit the following two files (you’ll need to unzip, edit the file, and re-zip):
%programfiles%\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplatesCache\VisualBasic\Windows\1033\WPFApplication.zip\MyWpfExtension.vb%programfiles%\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\VisualBasic\Windows\1033\WPFApplication.zipDid I mention that the former action is not a supported scenario by Microsoft or endorsed by the product teams? Yes, good.