Changing the namespace of a Silverlight 3 project (in VS2008)

Say you want to change the namespace of your Silverlight 3 app (this should work for Silverlight 2 too) from the default,

namespace SilverlightApplication1
namespace My.Silverlight.Prototypes.Demo

Then the changes you need to make in the code are,

1. Change the namespace in App.xaml.cs and in App.xaml change the x:Class,

<Application xmlns=""

2. Change the namespace in MainPage.xaml.cs and in MainPage.xaml change the x:Class,

<UserControl x:Class="My.Silverlight.Prototypes.Demo.MainPage"
    Width="400" Height="300">

3. Trying to run the app now will result in an error,

Error: Sys.InvalidOperationException: InitializeError error #2103 in control ‘Silverlight1’: Invalid or malformed application: Check manifest

4. This is because the startup object is wrong, right-click the SilverlightApplication1 and select ‘Properties’, and make sure the ‘Startup object’ is set to ‘My.Silverlight.Prototypes.Demo.App’.


5. Everything should run now, though I recommend changing the assembly name, default namespace, and xap file name,


6. If you follow step 5, don’t forget to change your aspx/html page to point to the new xap file,

<asp:Silverlight ID="Silverlight1" runat="server" Source="~/ClintBin/My.Silverlight.Prototypes.Demo.xap" 
MinimumVersion="3.0.40307.0" Width="100%" Height="100%" />


else, you’ll get the following error, because the aspx page couldn’t find the xap file.

Error: Sys.InvalidOperationException: InitializeError error #2104 in control ‘Silverlight1’: Could not download the Silverlight application. Check web server settings

Note: If your Silverlight content doesn’t show up in your aspx/html page after step 6, make sure you Clean and Rebuild your Silverlight application and regenerate your xap file by deleting it.

Digg This

About soumya chattopadhyay
I live and work in Seattle, WA. I work with Microsoft technologies, and I'm especially interested in C#.

6 Responses to Changing the namespace of a Silverlight 3 project (in VS2008)

  1. Morten Grøtan says:

    Thanks a bunch!
    My renamed app just showed as whitespace (without any error message) until I performed step 6 (clean and build).

  2. Rushira says:

    Thank u very much for the clear steps

  3. Hello, I found this blog post while searching for help with Microsoft Silverlight. I have recently changed internet browser from Opera to IE. Just recently I seem to have a problem with loading websites that have Microsoft Silverlight. Everytime I go on a website that requires Microsoft Silverlight, my browser crashes and I get a “npctrl.dll” error. I cannot seem to find out how to fix the problem. Any aid getting Microsoft Silverlight to work is very appreciated! Thanks

  4. Sonu200631 says:

    Thnx for this

  5. What’s up to all, how is everything, I think every one is getting more from this site, and your views are nice in support of new viewers.

  6. webpage says:

    Fantastic goods from you, man. I have be aware your stuff previous to and you’re just too magnificent. I actually like what you have received right here, really like what you’re stating and
    the way in which in which you are saying it.
    You’re making it entertaining and you still care for to stay it smart. I cant wait to learn much more from you. That is actually a great web site.

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

%d bloggers like this: