Skip to main content

Microsoft Silverlight

Answered Question Package Blend 2.5 SL 1.0 Projects with JSRSS Feed

(0)

ap0110
ap0110

Member

Member

20 points

9 Posts

Package Blend 2.5 SL 1.0 Projects with JS

I'm developing a simple SL 1.0 project using Blend 2.5 March 2008 Preview. I'm having a heckuva time getting the xaml.js to execute.

Here's what my .zip contains:

  • Page.xaml
  • Page.xaml.js
  • [media files]
  • manifest.xml

And the contents of manifest.xml:

<?xml version="1.0" encoding="utf-8" ?>
<SilverlightApp>
   <source>Page.xaml</source>
   <onLoad>CreateSilverlight()</onLoad>
   <version>1.0</version>
   <width>640</width>
   <height>480</height>
   <inPlaceInstallPrompt>true</inPlaceInstallPrompt>
   <jsOrder>
      <js>http://agappdom.net/h/silverlight.js</js>
      <js>Page.xaml.js</js>
   </jsOrder>
</SilverlightApp>

 
Am I missing something in the manifest file? Should I be adding something in Page.xaml or Page.xaml.js? Should I include anything from Default.html or its javascript? So far I've found around 5 or 6 DIFFERENT techniques for packaging for SL Streaming and none of them are working or match up with the default files in Blend 2.5.

Thanks

 

ap0110
ap0110

Member

Member

20 points

9 Posts

Answered Question

Re: Package Blend 2.5 SL 1.0 Projects with JS

Ok, I finally found the answer. Hopefully I'm not being a total idiot and someone can actually benefit from this, because I swear I haven't found this anywhere except for one blog entry.

In the absence of an html file and all the code that goes with that, you need something to kick off the javascript. So I changed the above manifest.xml to the following:

<?xml version="1.0" encoding="utf-8" ?>
<SilverlightApp>
   <source>Page.xaml</source>
   <onLoad>onLoad</onLoad>
   <version>1.0</version>
   <width>640</width>
   <height>480</height>
   <inPlaceInstallPrompt>true</inPlaceInstallPrompt>
   <jsOrder>
      <js>Page.xaml.js</js>
      <js>PlayThisShite.js</js>
   </jsOrder>
</SilverlightApp>

Note that I changed the onLoad and took out the silverlight.js, then added a new js file. Here's the content of PlayThisShite.js:

Silverlight.createDelegate = function(instance, method) {
   return function() {
   return method.apply(instance, arguments);
   }
}

function onLoad(sender, context, source)
{
       var scene = new SL1Test.Page();
       scene.handleLoad(sender, context, source);
}

SL1Test is the name of my project. When I started the project in Blend 2.5 (I haven't tried Blend 2 in awhile but it's probably the same), these are the first few lines of the default. Page.xaml.js file:

if (!window.SL1Test)
    SL1Test = {};

SL1Test.Page = function()
{
}

The project works fine now. Btw, here's what I'm using for this project:

  • Expression Blend 2.5 March 2008 Preview
  • Silverlight Streaming Beta
  • Silverlight 1.0 Runtime (Release version)

Thanks

cigdem
cigdem

Member

Member

44 points

1 Posts

Re: Package Blend 2.5 SL 1.0 Projects with JS

I had some problems with the manifest.xml, but realized that I had to create the ZIP file inside the project directory level and not at the directory  level. When I made that discovery, I also tried out your solution and it worked, however using your manifest.xml or using the manifest.xml seen below made no difference:

<?xml version="1.0" encoding="utf-8" ?>
<SilverlightApp>
   <source>Page.xaml</source>
   <version>1.0</version>
   <width>640</width>
   <height>480</height>
   <jsOrder>
      <js>Page.xaml.js</js>
   </jsOrder>
</SilverlightApp>

Right now, there are no further problems, but I wanted to share my experiments, because I am using the same tools you listed down:

Blend 2.5
Silverlight Site project - SL1.0
Silverlight Streaming Beta

Thanks.

Frogs69
Frogs69

Participant

Participant

798 points

219 Posts

Microsoft

Re: Package Blend 2.5 SL 1.0 Projects with JS

I am sorry to see you could only find the answer to your issue on that one blog posting (see more references below), and that I only got to read your post now...

  • The first issue was that <js>http://agappdom.net/h/silverlight.js</js> should not be in your manifest. This is part of the header on your web page where you want to expose your app hosted in SLS.
  • The second issue was that CreateSilverlight() belongs in CreateSilverlight.js which must live on your web server, and should also not be in your manifest.

Out of curiosity, did you check the SLS SDK and if yes did it not help you out? I am thinking in particular of the following page: http://msdn2.microsoft.com/en-us/library/bb851612.aspx

Additional info about cigdem's reply.

  • inPlaceInstallPrompt is set by default to True, so unless you set it to False, it is the same as not having it by design, unless you specify it elsewhere in your app.
  • jsOrder only matters for the scripts that must load in a particular order, once those are loaded, the others will be loade in whatever order IE sees fit, but it shouldn't matter for your app.

IMPORTANT TO NOTE: we actually want to deprecate this JavaScript invocation syntax, and while it is still supported, the preferred invocation syntax is the iframe (http://msdn2.microsoft.com/en-us/library/bb802533.aspx) and the Windows Live control (http://msdn2.microsoft.com/en-us/library/cc304460.aspx). Both are much simpler, and the latter will get richer over time to become more powerful than the script invocation syntax.

A couple additional blog references:

 

ap0110
ap0110

Member

Member

20 points

9 Posts

Re: Re: Package Blend 2.5 SL 1.0 Projects with JS

Thank you for the links. Are these new posts? I searched all over MSDN and found about 4 or 5 DIFFERENT instructions for packaging these files, none of which are the links you have here. (Please don't ask me to remember where I found all the bad information.)

I haven't tried your suggestions yet. I've been in "just get it done" mode.
 

Frogs69
Frogs69

Participant

Participant

798 points

219 Posts

Microsoft

Re: Re: Package Blend 2.5 SL 1.0 Projects with JS

They are not really new posts. We released the SDK at the same time as the service and we kept updating it to make sure it was on par with the service updates...

Cheers.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities