Silverlight “Name ‘InitializeComponent’ is not declared”


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:




To the new project namespace:





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


6 responses »

  1. Another possible solution for this is to reset the namespace cache. Go to Project in the menu, and to [Name of your project ] Properties… at the bottom.

    Where it says Root namespace: , clear the textbox and press Save.

    Once it has saved (it can take a few seconds), rebuild your project. It will fail to rebuild.

    Next go back to the properties, and put the namespace back to what it was before. Hit save, rebuild, and with any luck Visual Studio will have fixed your issues.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s