Namespace changes with Silverlight 8.1

Today I’m going to talk about the dreaded namespace changing (this also applies to project renaming). Most of the time, when you decide to change the project name and or namespaces in an application, there is almost always some hidden issue that pops up. It has been my experience that there is usually a different ‘gotcha’ with each application type (For example Windows Phone, Windows Phone Silverlight, ASP.NET MVC application etc..). This particular article will focus on a Silverlight application.

I have posted several namespace type posts before. One in particular here that relates to changing namespaces in an MVC application and how it changes the way routes are interpreted. I will be talking about another recent issue I had with namespaces and WebAPI in a future post.

What most seem to miss in Silverlight Application project / namespace changes (Including myself).

So I recently changed the namespace on one of my personal projects due to my personal issues with perfection and anal retentiveness for everything to be consistent and unambiguous.  After doing this, I followed the typical steps most do when doing a rename like this. These entail the following:

  1. Update the Assembly information to match the new namespace.
  2. Update the WMAppManifest.xml file Packaging section.
  3. Update the App.xaml to reflect the new x:Class section.
  4. Update any XAML files to the new namespace. Update both the .cs and .xaml file (The .xaml files are updated in the x:Class section at the top of the page).
  5. Update all classes to use the new namespaces.
  6. Update the Package.appmanifest file with the proper entry point if updated and the Packaging section.
  7. Clean out (delete not just run a clean) the obj  and bin folders.
  8. Rebuild the project. This will ensure that the files associated with the project are renamed appropriately to match the new namespace and project name changes. Not doing this can cause adverse affects.

After doing all of these things, most of the time, you have covered all your basis and everything will build successfully and run as expected…. but not alwaysSad smile.

So.. What happened?

Funny you should ask. So I built the project asfter doing everything above and I got a successful build. So we are good right? Wrong! Once I started the project in debug mode, I always got an AgHost.exe exited error, but no diagnostics would run. No exception thrown. No nothing. The complete error I got every time was as follows:

AgHost.exe’ has exited with code -532265403 (0xe0464645)

The key here is the code. –532265… Usually, the exit code is –1, which is pretty much exiting the application, but expectedly. About an hour after Goggling the error code, I found an interesting SO post. There seems to be a bug in Visual Studio 2013 and 2015 that causes the Startup Object  in the Properties section to be empty. To get to this section, right click the project and go to Properties => Application => Startup Object. See below for a visual.

StartupObjectimage

Where it says not set, you should set this from the dropdown to the desired start App XAML file.

 

Hope this helps others from pulling their hair out.

Happy Coding Smile!

Advertisements

About Gregg Coleman

I am Senior-level Software Engineer working primarily these days with .NET. I have a good working knowledge of ASP.NET MVC, Web Forms, WCF web services and Windows Services. I spend much of my time in the Web Services (SOAP and REST) world in my current job designing and implementing various SOA architectures. I have been in the software engineering industry for about 6 years now and will not now nor ever consider myself an "expert" in programming because there is always so much to learn. My favorite thing about designing software is there are always new emerging technologies and something to learn every day! My current job has me spending much of my job on the bleeding edge of technologies and changing gears all the time, so I'm never bored and always challenged. On my spare time I enjoy weight training, reading and venturing to new places near by. Of course programing and learning new technologies are another hobby of mine.
This entry was posted in .NET, C#, Classes, MVVM, Namespaces, New apps, Programming, Silvelight, Web Technologies, Windows Apps, Windows Phone, Windows Phone, Windows Store Apps. Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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