Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

usercontrol hosted in IE renders as a textbox

On my ongoing saga to mirror the hosting of a legacy app on a clean box, I've hit my next snag. One page relies on a big .NET UserControl that on the new machine renders only as a big, greyed out textarea (greyed out vertical scrollbar on the right hand edge. Inspecting the source shows the expected object tag.)

This is particularly tricky because nobody seems to know much about hosted UserControls and all the discussions data back to 2002-2004.

The page is quite simple:

<%@ Page language="c#" Codebehind="DataExport.aspx.cs" AutoEventWireup="false" Inherits="yyyyy.Web.DataExport" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 

<html>
  <head>
    <title>DataExport</title>
    <link rel="Configuration" href="/xxxxx/yyyyy/DataExport.config">
  </head>   
    <body style="margin:0px;padding:0px;overflow:hidden">
        <OBJECT id="DataExport" style="WIDTH: 100%; HEIGHT: 100%; position:absolute; left: 0px; top:0px"
            classid="yyyyy.Common.dll#yyyyy.Controls.DataExport"
             VIEWASTEXT>
        </OBJECT>
    </body> 
</html>

The config file referenced:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="yyyyy">
            <section name="dataExport" type="yyyyy.Controls.DataExportSectionHandler,yyyyy.Common" />
        </sectionGroup>
    </configSections>
    <yyyyy> 
        <dataExport>
            <layoutFile>http://vm2/xxxxx/yyyyy/layout.xml</layoutFile>      
            <webServiceUrl>http://vm2/xxxxx/yyyyy/services/yyyyy.asmx</webServiceUrl>
        </dataExport>   
    </yyyyy>    
</configuration>

What I've checked:

  • Security permissions should be OK, the site is trusted and adding a URL exception to grant FullTrust doesn't change anything.
  • Config file is acessible over the web, layout.xml is accessible, ASMX shows the expected command list
  • Machine.config grants GET permission for the usercontrol.config file.

What perhaps looks fishy to me:

  • The DataExport UserControl references Aspose.Excel to generate the spreadsheets it exports.
  • When I navigate to the page and get a blank textbox, then run gacutil /ldl, nothing is in the local download cache. On the working machine, running the same command after viewing the page shows a laundry list of DLLs including the control DLL and the Aspose DLL.
like image 397
Coxy Avatar asked Jun 03 '10 03:06

Coxy


1 Answers

This is actually taken from an answer I gave to a completely different question: Creating and deploying an ActiveX control in .NET.

...

It's easy to debug the control if you compile for debug and attach to IE for "managed" debugging once you get the control to load. If you can't get the control to load, look up info on the fusion assembly binding viewer: http://msdn.microsoft.com/en-us/library/e74a18c4.aspx and how to turn on IEHost tracing: http://support.microsoft.com/kb/313892 in order to debug the load process.

Be sure to version every version of the assembly. If you don't, then IE gets confused and won't load the control when the assembly in the download cache is different but has the same version # as the one the url references (gacutil /cdl clears the .net download cache)

...

There are other links in that answer to info on IE hosted controls that might help, but it sounds like you've already been through them.

Another reason a control might not load depends on what version of IE you're using. IE8 requires the control come from the intranet or trusted zone. I don't know if this changed in IE9 or not. But of note is that "localhost" is not in the intranet zone and not by default in the trusted zone. This often trips people up who are testing the client UI on the web server.

like image 175
Tony Lee Avatar answered Oct 12 '22 22:10

Tony Lee