Visual Studio and .NET Framework Home
App.InitializeComponent is not generated when StartupUri and Startup are missing
8/27/2008 9:27:08 AM
User(s) can reproduce this bug
UPDATE: I attached a zip that demonstrates the issue. The readme.txt file in the solution goes into further detail.
I'm entering this as a bug although I suppose it's possible that it is by design. I discovered this while playing around with the StockTraderRI application from WPF Composite Guidance. Basically if the Startup and StartupUri attributes are not set on the Application tag in App.xaml, the App.g.cs file does not contain the InitializeComponent method. This means that the resources do not appear to be loaded when accessing them through Application.Current.Resources. I'm not sure if it causes any other problems, but that is the symptom I noticed.
Visual Studio 2008 Service Pack 1
Operating System Language
Steps to Reproduce
Create a WPF Application.
Remove the StartupUri (and Startup attribute if present) from the Application tab in App.xaml.
Add some resources to Application.Resources in App.xaml.
Override OnStartup and set a breakpoint after calling base.OnStartup.
Check Application.Current.Resources and notice the collection is empty.
Resources collection is empty
Resources should be loaded even if StartupUri and Startup are not provided. I understand that one of those two should logically be provided, but if someone overrides OnStartup only as in the StockTraderRI, then InitializeComponent should be gen'ed and called. I realize that the XAML generator may have problems with seeing that is overrided though.
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 7/19/2012 at 10:12 PM
The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.
on 3/16/2012 at 1:31 PM
I'm seeing the same issue in VS 2010, but only recently did it start doing this. I've create dozens of WPF Application projects before, removed the StartupUri or Startup tags and the InitializeComponent method is still generated. For soem reason now, it magically is not doing it.
on 12/3/2010 at 11:15 AM
Repro Steps are posted at
on 7/11/2010 at 12:14 PM
This issue still exists in VS 2010 :-(.
on 9/12/2008 at 12:45 AM
The easiest workaround is to set the x:Name attribute on the <Application> element in XAML. Then InitializeComponent() will be generated and called, and the ResourceDictionary will be loaded.
on 8/31/2008 at 8:08 PM
We were able to reproduce the issue you are seeing according to your feedback. We are escalating this bug to the product unit who works on that specific feature area. The product team will review this issue and make a decision on whether they will fix it or not for the next release
on 8/28/2008 at 7:06 AM
I attached a zip that demonstrates the issue. The readme.txt file in the solution goes into further detail.
on 8/28/2008 at 12:34 AM
Thanks for reporting the issue.
In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.
It may help if you provide us with:
a zipped project file
It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 7 days, we will close this issue
Thanks again for your efforts and we look forward to hearing from you.
Visual Studio Product Team
to post a workaround.
Please enter a workaround.
© 2013 Microsoft