none
Code: 2104 Unhandled Error in Silverlight Application

    Question

  • The Silverlight application (xap) file is compiled to target AnyCPU but all other components of the website have been compiled for x86. The server-side components have to run in x86 mode because they have to use the Microsoft Jet driver. This is a requirement.

    After extensive debugging I have failed to find a solution. I have a suspicion it might be some kind of permissions issue but I haven't been able to identify it.

    The application works flawlessly when it is run locally on a x86 development machine but fails on the server environment.

    Please see below for a list of things I've tried with additional debug info.

    ----------------------
    Server: Windows Server 2003 x64, IIS 6 running x86 application pool

    App: Silverlight 4

    ----------------------

    The following has been verified:

    - the 3 standard MIME types (xap, xbap and xaml) have been associated with both the IIS process and the website

    - .NET Framework v4 is installed on the server

    - aspnet_iisreg -i has been executed to register .NET v4 x86 with IIS

    - file permissions have been verified for the deployment directory and full access has been given to Everyone

    - the .xap file exists in the clientbin/ directory

    - The application pool has been set to allow 32-bit processes via

      cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

    ----------------------

    I have resorted to using a simple "Hello world"-style test app to reduce the sources of error but the 2104 error persists.

    ----------------------

    Symptoms that have been identified are:

    - By enabling browsing, I can see the xap file but can't actually download it. I get the response: "The system cannot find the file specified."

    - IIS log files show the following error when a client requests the page:

    2012-01-11 19:18:40 10.161.4.38 GET /ClientBin/Lab1.xap - 80 - 10.161.4.38 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+WOW64;+SV1;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729;+.NET4.0C;+.NET4.0E) 404 0 2 231 301 0

    ----------------------

    The test application's aspx file is given below:

    ----------------------

    <%@ Page Language="VB" AutoEventWireup="true" %>

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head runat="server">

        <title>Lab1</title>

        <style type="text/css">

        html, body {

                        height: 100%;

                        overflow: auto;

        }

        body {

                        padding: 0;

                        margin: 0;

        }

        #silverlightControlHost {

                        height: 100%;

                        text-align:center;

        }

        </style>

        <script type="text/javascript" src="Silverlight.js"></script>

        <script type="text/javascript">

            function onSilverlightError(sender, args) {

                var appSource = "";

                if (sender != null && sender != 0) {

                  appSource = sender.getHost().Source;

                }

               

                var errorType = args.ErrorType;

                var iErrorCode = args.ErrorCode;

     

                if (errorType == "ImageError" || errorType == "MediaError") {

                  return;

                }

     

                var errMsg = "Unhandled Error in Silverlight Application " +  appSource + "\n" ;

     

                errMsg += "Code: "+ iErrorCode + "    \n";

                errMsg += "Category: " + errorType + "       \n";

                errMsg += "Message: " + args.ErrorMessage + "     \n";

     

                if (errorType == "ParserError") {

                    errMsg += "File: " + args.xamlFile + "     \n";

                    errMsg += "Line: " + args.lineNumber + "     \n";

                    errMsg += "Position: " + args.charPosition + "     \n";

                }

                else if (errorType == "RuntimeError") {          

                    if (args.lineNumber != 0) {

                        errMsg += "Line: " + args.lineNumber + "     \n";

                        errMsg += "Position: " +  args.charPosition + "     \n";

                    }

                    errMsg += "MethodName: " + args.methodName + "     \n";

                }

     

                throw new Error(errMsg);

            }

        </script>

    </head>

    <body>

        <form id="form1" runat="server" style="height:100%">

        <div id="silverlightControlHost">

            <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">

                                      <param name="source" value="/ClientBin/Lab1.xap"/>

                                      <param name="onError" value="onSilverlightError" />

                                      <param name="background" value="white" />

                                      <param name="minRuntimeVersion" value="4.0.50826.0" />

                                      <param name="autoUpgrade" value="true" />

                                      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">

                                                     <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>

                                      </a>

                        </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>

        </form>

    </body>

    </html>

    Wednesday, January 11, 2012 2:45 PM