Quick Silverlight Tip: "InitializeError #2103 - Invalid or malformed application" what is it and how to deal with it?
Today I've seen very strange and unpleasant error while trying to run some freshly created Silverlight application. It said:
Invalid or malformed application: Check manifest
Fast search by popular search engines gave me this and this places, but everything mentioned there I've already knew or tried before... So what is it? Let's see what it was and how it was solved. Let's reproduce it.
I'm creating new Silverlight 2 project, compiled it it works... My simplest project looks like follows (every button click just adds "!" to Button.Content):
Everything works fine, until I decided to change the namespace in your class.
When changing the namespace in you Page.xaml.cs don't forget to change it also in Page.xaml, App.xaml.cs and App.xaml. This is known, and I did it.
After compiling and lunching the application I received this:
(if I used <asp:Silverlight/> in a ASP.NET page)
(if used <object/> in a HTML page)
Why it happened?
I did the change in all files, I recompiled the project, I have checked that MIME type for ".XAP" is set to "application/x-silverlight" (in case I'm running from real web server and not from ASP.NET Development Server) , I've even cleared the browser's cache...
After checking AppManifest.xml in XAP file I've identified the problem.
The think was missed... ... ... application startup object in project properties!
It was still pointing to "Old Namespace".App!
And thus, AppManifest.xml in XAP file was generated like follows (with EntryPointType pointing to non-existent place):
1: <Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
2: EntryPointAssembly="NamespaceChange" EntryPointType="NamespaceChange.App" RuntimeVersion="2.0.30523.4">
4: <AssemblyPart x:Name="NamespaceChange" Source="NamespaceChange.dll" />
The only thing needed to be done is to change Startup object in Visual Studio Project Properties and recompile.
Now the manifest generated as it should be and the application works!
So, next time when you changing the namespace don't forget to change the startup object.