Thursday, January 31, 2008 12:48 PM
Right I have looked through the fourms to see if this question was perviously asked and it appears that it has but, I have failed to see where they have been answered: I have deleted and re-installed my Silverlight files necessary for dveloping silverlight app in visual studio. I'm using VS 2008, and have created a simple silverlight app called Howdy Silverlight.
I have changed the .csproj adding :
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
and I still get the following error:
Error 2 The name 'InitializeComponent' does not exist in the current context C:\Users\DM\Documents\Visual Studio 2008\Projects\HowdySilverlight\HowdySilverlight\Page.xaml.cs 18 13 HowdySilverlight
and the page.xaml.cs:
public partial class Page : Canvas
public void Page_Loaded(object o, EventArgs e)
// Required to initialize variables
The following web references:
agclr, mscorlib , system, system.core, system.silverlight, system.xml.core
are also referenced.
Would greatly appericate a solution this problem,
Thursday, January 31, 2008 1:09 PM
The Import you're using is for WPF and silverlight is not WPF at all. The initialize component is created from the XAML file's code generator. If you don't have it correctly setup, it won't build the .g file that is necessary. Typically this is making sure that the "CustomTool" of the .xaml file says "MSBuild:CompileXaml"
Thursday, January 31, 2008 1:33 PM
What .g file. ? and what which customTool do you refer? None of the tutorials on silver.net make mention of this, so could be a bit more specific.
Thursday, January 31, 2008 2:24 PM
OK, I'm calm now, and understand the MSBuild:CompileXaml Options setting, silliy overlook on my part! Thanks
Thursday, January 31, 2008 4:31 PM
Sorry, fi you have the MSBuild:CompileXaml set in your .xaml file, when you save the file it will build a page.xaml.g file in the obj directory that it uses during compilation. This is the generated part of the code.
Thursday, December 11, 2008 5:33 PM
You also get this error if you rename the class and forget to update the XAML.
Friday, February 27, 2009 3:38 PM
IWolf is absolutely right. Thanks :P
Wednesday, August 05, 2009 1:46 PM
I also have the same problem. Can you please tell me where did you do changes, in what files and fill attributes and what values you set since I am new to Silverlight
Sunday, April 25, 2010 2:26 PM
worth a read also.
Thursday, April 29, 2010 9:19 AM
I get the same error, and i found this page:
[Figured out my issue. Sometime in the course of coding, I must have deleted the inital x:Class="TwitterSearchMonitor.Views.Search" from the first line of my Search.xaml. I put that back in and it's working now. :)]
And i fixed the error with the same way.
Hope this help.
Tuesday, May 18, 2010 12:58 AM
Post time 5/17/2010
If people have come across this and have not gotten a solution through this post I have come up with a possible fix.
Tools: Visual Studio 2008 and MS Blend 2
This same error can be replicated if you assign an event handler to an object in your xaml file but do not have an event in your xaml code. behind. This can occur on occasion when using MS Blend to assign events and visual studio is slow in responding or you make two event changes in in Blend without updating and apply the changes in visual studio.
<TextBox x:Name="txtURL" Text="None" Height="24" Margin="0,0,160,0" VerticalAlignment="Top" TextChanged="txtURL_TextChanged"/>
Private Sub txtDebug_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs)
In the above case page.xaml.vb has an event handler for txtDebug but not for txtURL. This original posters error concern can be replicated when using this description and silverlight 2
Friday, June 17, 2011 3:55 PM
I solved my problem by fixing the namespace difference between my xaml and cs file.
Thursday, July 12, 2012 3:17 PM
Bingo - thanks for the tip. I had copied some Xaml files from the Sliverlight Navigation template-generated project. I changed the namespace in the .cs files, but neglected to update the namespace in the first line of the Xaml file.
Thursday, September 13, 2012 6:56 PM
ditto ... I had changed the app.xaml.cs namespace but did not immediately recongize the the spot for that namespace in app.xaml.
x:Class="<put your app.xaml.cs namespance here>"