Help and Support
 

powered byLive Search

Error message when you compile a WPF application in Visual Basic 2008: "Option Strict On disallows implicit conversions"

Article ID:945756
Last Review:December 3, 2007
Revision:1.0

SYMPTOMS

You may receive an error message that resembles the following when you try to compile a Windows Presentation Foundation (WPF) application in Microsoft Visual Basic 2008:
Option Strict On disallows implicit conversions from 'System.Windows.Application' to 'WpfApplication1.Application'.

Back to the top

CAUSE

This issue occurs if the value of the Option Strict statement is "On" at the project level.

Back to the top

RESOLUTION

To resolve this issue, download an updated WPF template. To obtain the updated template, visit the following Microsoft Web site:
http://go.microsoft.com/fwlink/?LinkId=105130 (http://go.microsoft.com/fwlink/?LinkId=105130)
Important You do not have to unzip the compressed file with a .zip file name extension to install the updated template. To install the updated template, put the .compressed file with a .zip file name extension in the \Visual Studio 2008\Templates\ProjectTemplates\Visual Basic folder, and then restart Visual Studio 2008.

After you install the updated template, the updated template appears in the New Project dialog box in the My Templates section. This section is located under the Visual Studio installed templates section.

Back to the top

WORKAROUND

To work around this issue in the current project, modify the code in the Mywpfextension.vb file. To modify the code in the Mywpfextension.vb file, follow these steps:
1.Under Error List, double-click the error message that the "Symptoms" section describes. The Mywpfextension.vb file opens.
2.Locate the following line of code:
Return Global.System.Windows.Application.Current
3.Modify the code in step 2 as follows:
Return CType(Global.System.Windows.Application.Current, Application)
4.Build the project again.

Back to the top

MORE INFORMATION

This issue occurs because the code in the WPF template performs an implicit cast. Implicit casts are not allowed when Option Strict checking is turned on.

Back to the top

REFERENCES

For more information about the Option Strict statement, visit the following Microsoft MSDN Web site:
http://msdn2.microsoft.com/en-us/library/zcd4xwzs(VS.80).aspx (http://msdn2.microsoft.com/en-us/library/zcd4xwzs(VS.80).aspx)

Back to the top


APPLIES TO
Microsoft Visual Studio 2008 Standard Edition
Microsoft Visual Studio 2008 Professional Edition
Microsoft Visual Studio 2008 Team Edition for Database Professionals
Microsoft Visual Studio 2008 Team Edition for Software Architects
Microsoft Visual Studio 2008 Team Edition for Software Developers
Microsoft Visual Studio 2008 Team Edition for Software Testers
Microsoft Visual Studio 2008 Team Suite
Microsoft Visual Basic 2008 Express Edition

Back to the top

Keywords: 
kbtshoot kbprb KB945756

Back to the top

Article Translations

 

Related Support Centers

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.