Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call .Net assembly from OBJECT tag in IE8

I have a web page that calls a .Net assembly. Everything works fine in Windows XP and IE7. The relevant parts:

<html>
<head>
    <script language="javascript" type="text/javascript">
    function doScript() {
        myControl1.Go("value1","value2");
    }
    </script>
</head>
<body onload="javascript:doScript();">
    <object id="myControl1" name="myControl1" 
            codebase="../cabs/myassembly.dll" 
            classid="../cabs/myassembly.dll#MyNs.MyClass" 
            width="1" height="1"></object>
</body>
</html>

I cannot get this to work in Windows 7 with IE8. Some notes:

  • The assembly is strong named.
  • I am hosting this on localhost right now.
    • On the machine that is working (VirtualBox-hosted WinXP, IE7), it is using an IP address to my local machine (http://1.2.3.4/...) and that IP is in the "Trusted Sites" of IE.
    • On the machine that is not working (Windows 7, IE8), it is using http://localhost/... and localhost is in the "Trusted Sites" of IE.
  • The assembly is being served from http://localhost/cabs/myassembly.dll.
  • The error message is a javascript error, "Object doesn't support this property or method"
  • Fiddler shows a 200 OK response when the file is requested, however, it does not appear that the dll is making it to the temporary internet files location.
  • The site is running in "IE 7 compatibility" mode.
  • I have dropped all IE permissions to the most insecure it will let you in all zones, and the behavior is exactly the same.

Does anyone have any ideas to try to get this to work or troubleshoot where the problem is at?

Disclaimer: Yes, I realize it is 2012, and the world has moved past IE7, IE8, ActiveX, etc. Let's just say we're a little bit behind technologically. This is the problem I have to solve; upgrading to modern solutions isn't going to be an option.

UPDATE: I did get it to work in a Windows XP VirtualBox running IE8. So it appears the problem is specific to Windows 7. It fails both on my local machine and a VirtualBox running Windows 7, IE8.

like image 829
Dave Mateer Avatar asked Aug 31 '12 16:08

Dave Mateer


2 Answers

This was solved by adding the registry key answered on "Loading .NET UserControls in IE with .NET 4.0" (even though this was a 2.0 control)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]
"EnableIEHosting"=dword:00000001
like image 152
Dave Mateer Avatar answered Nov 04 '22 03:11

Dave Mateer


I'm not sure that this will help, but I have had a similar issue and this has usually fixed it. Try these steps on the machine where it's not working.

  1. Assign the domain of the url where the dll is located to the Trusted sites zone.
  2. Open the Security tab in Internet Options and click Trusted sites
  3. Click Default level and make sure that it selects Medium. If not, manually set it to Medium.
  4. Apply

For good measure, close all IE windows and then relaunch and test if it works.

The key issue is the one that was discussed in the page that rene linked to in his second comment. As of IE8 and onwards, there is a security setting that does not have it's own UI in the Custom level list of options. The only way to affect it is by setting the Level - Medium or lower sets it to Enable while Medium-high higher sets it to Disable.

Now this might very well not be your problem, since usually the default level for Trusted sites is Medium which would enable the setting. But it's worth trying at least (maybe you have some Group Policy or something that has changed the default level of Trusted Sites).

like image 37
user1429080 Avatar answered Nov 04 '22 01:11

user1429080