Jimmy Schementi Jimmy.Schementi at microsoft.com
Mon Jan 12 22:24:09 CET 2009

> xkrja wrote:
> I have an IronPython app made for Silverlight 2 and I have problems to
> get it to load properly on the web page. There are several JavaScripts
> in the HTML-page together with the SL2  and that seems to cause
> problems. In 30% or so of the times I start up the application (from
> VS Web Dev express and Chiron) the SL2 will not load. The error says:
>
> InitializeError- Invalid or malformed application: Check manifest
>
> As I said, this happens approx 30% of the times I run the web page. I
> assume it is because of the Javascript on the page and since it is
> of the SL2 object.

There shouldn't be an issue loading a Silverlight application with other Javascript that does things on document.ready. This error seems like something to do with the browser trying to load the XAP file before Chiron has a chance to create it. That error message only happens if the there is something wrong with the loaded manifest file.

> So now I want to load the SL2 app using JavaScript instead of the  but
> I
> can't get it to work. My idea is that if I use Javascript to load the
> SL2
> app, then I can configure it to be loaded last and hopefully it won't
> interfere with any of the other scripts on the page. Maybe this idea is
> completely wrong so please correct me if you think so!

I still don't see how it could be interfering with other scripts on the page; it's just a <object> tag, and if has its own <div> then it won't touch the rest of the page. Unless your Silverlight app looks at the DOM as well. In that case, you need to be checking for HtmlPage.DocumentReady (or something like that). Loading it with javascript will work as well, but how are you going about doing that? I personally would use the Silverlight.js file in the Silverlight SDK (c:\program files\microsoft sdks\silverlight), but you could just do it by hand too.

> Anyway, my questions:
>
> 1) Do I need to pre-build the application's app.xap file in order to
> load it with JavaScript? I can't get it to load the app using
> Javascript if I just use the "/b" extension in the "start options"
> of Chiron (in VS Web dev express). BUT if I use a pre-built .xap file
> (from another application) it works.

No need for a pre-build XAP, if Chiron is the web server. When Chiron gets a request for http://localhost:2060/myapp/app.xap, it looks for a directory "<rootDir>\myapp\app", and if it exists Chiron does the equivalent of /zipdlr in memory, and returns the data as the response. When running Chiron /b, does Chiron log a request of the xap?

> 2) If I need a pre-built .xap-file, how do I do that properly? I tried
> using
>
> chiron.exe /x:app/app.xap
>
> and it gives me a .xap-file but it doesn't work. All files seems to be
> in it but strangely it doesn't work.

When you run "Chiron.exe /?" it will tell you that /xap just XAPs the contents of a folder, while /zipdlr will generate the AppManifest.xaml if needed, and stick the DLR/Language assemblies in the XAP, if needed, on top of xaping the directory as well. So, you need Chiron.exe /z:path\to\app.xap.

> Thanks for any help that can get me on the right track!

Let me know if you have any other questions. For more Silverlight+DLR specific issues, you can as on this discussion list: http://www.codeplex.com/sdlsdk/Thread/List.aspx.

If you still can't get it to work, please try to create a small reproduction of the issue and open a bug here: http://www.codeplex.com/sdlsdk/WorkItem/List.aspx, and I'll investigate.

~Jimmy