BlockLeftTop, PRELOAD BlockLeftBottom, PRELOAD BlockLeftStretch, PRELOAD BlockTop, PRELOAD BlockBottom, PRELOAD BlockStretch, PRELOAD BlockRightTop, PRELOAD BlockRightBottom, PRELOAD BlockRightStretch, PRELOAD
DeltaEngine

Fixing the Sys.Res. namespaceContainsObject error with ASP.NET Ajax+Silverlight

by Benjamin Nitschke 17. July 2007 18:58
When you try to implement a Silverlight project into an existing ASP.NET Ajax
website you will just click Add Silverlight link to a specific directory in your
website (don't spam everything into your main directory). Then you might want
to use same the html code from your test sites in the ASPX page, like this:

<head runat="server">
  <title>Some title</title>
  <script type="text/javascript" src="Silverlight.js"></script>
  <script type="text/javascript" src="Default.aspx.js"></script>
</head>


And the SilverlightControlHost somewhere in the body (in the form).
You also might want to move the body onload method to a div panel in case you
are using a master page or you want multiple silverlight controls:

        <div id="SilverlightControlHost"
            onload="document.getElementById('SilverlightControl').focus()">
            <script type="text/javascript">
                createSilverlight();
            </script>
        </div>


You might be able to compile and start that without any problems, BUT if you
already have a lot of ASP.NET Ajax code you might end up with this error (and
a bunch more, most of them with Sys.Res in the error description).

Line: 967
Error: Sys.Res.namespaceContainsObject is null or not an object



The problem is that both Silverlight and some generated ASP.NET Ajax javascript
files use the same javascript object (Sys.Res), but overwrite it and disable the
functionality that is needed. You won't find much information on that with
google, but the solution is very simple! Just put the scripts directly into
your ScriptManager of the site like this and remove the scripts from the header:

        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Path="Silverlight.js" />
                <asp:ScriptReference Path="Default.aspx.js" />
            </Scripts>
        </asp:ScriptManager>

        
Hope this helps and saves you some time.

Comments


4/28/2010 3:48:39 AM #

I\'m happy I found this blog, I couldnt discover any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if possible feel free to let me know, i\'m always look for people to check out my site. Please stop by and leave a comment sometime!

Rapidshare | Reply


Add comment




biuquote
  • Comment
  • Preview
Loading



Disclaimer: The opinions expressed in this blog are own personal opinions and do not represent the companies view.
© 2000-2011 exDream GmbH & MobileBits GmbH. All rights reserved. Legal/Impressum

Poll

Which platform should Soulcraft be released on next?











Show Results Poll Archive

Recent Games

Soulcraft

Fireburst

Jobs @ exDream

Calendar

<<  May 2012  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910