An Original Idea

because all great software begins with an original idea

Silverlight “Name ‘InitializeComponent’ is not declared”

Posted by anoriginalidea on July 1, 2009

She'd be far less frutrated if she plugged it into the network first.

It is quite common in Webforms, Winforms and other environements to copy user interface views from one project to another.

When you copy xaml files from one Silverlight project to another you may experience the error:

“Name ‘InitializeComponent’ is not declared”

 

This happens because the “x:Class” directive in the top of the xaml file includes the project namespace.

So, open up your xaml file, and change this:

 

x:Class=”PreviousProject.YourClass”

 

To the new project namespace:

x:Class=”NewProject.YourClass”

 

Oh and BTW…..ITS CASE SENSITIVE! 

 

I know this isn’t much of a post, but hopefully it will provide a useful search engine hit for the desperate.


4 Responses to “Silverlight “Name ‘InitializeComponent’ is not declared””

  1. san said

    Actually helped me; I was pulling my hair out not noticing there is the difference in the top tag.

  2. NPSF3000 said

    Thanks very much, fixed major problems on a C# to VB WPF conversion.

  3. slapout said

    Thanks! That fixed the problem I was having when I copied some Xaml from one Silverlight project to another.

  4. Alan J said

    Thanks. I was scratching my head on this one.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>