« Working with Perforce Labels | Main | Community Starter Kit »

Embedded Windows Forms Control In Web Page, Bugs, Tips, Tricks, and Tools

There’s a major bug in security policy assignment affecting this functionality:

PRB: Security Exception When You Use Event Handlers in Internet Explorer

To turn off all assembly security policy checking: “caspol –s off”

or

Use the Framework Configuration tool to set the intranet zone to Full Trust.

Using permission sets and code groups doesn’t appear to work with strong name or url evidence.

It does work with site evidence.

 

.NET Framework Configuration Tool: Microsoft .NET Framework 1.1 Configuration

 

Got an example HTML page working with an embedded Windows.Forms.Panel derived control on it. Key syntax is:

 

Kizmet.MediSched.Controls.DayHourCalendar" id="mySched" VIEWASTEXT>

           

           

           

           

           

           

 

See also: Deploying a Runtime Application Using Internet Explorer

 

PRB: Cannot Host .NET User Controls in Internet Explorer 6.0 from File System

You can, but it has to be registered in the GAC, regasm.exe’d and use ActiveX syntax to load it:

<OBJECT ID="idtest" CLASSID="CLSID:9F769412-6736-39DD-9B29-DEF814E32B26" CODEBASE="mytest.dll#-1,-1,-1,-1">

 

List the contents of the download cache:

V:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\gacutil –ldl

 

Clear the download cache

gacutil –cdl

 

Host Secure, Lightweight Client-Side Controls in Microsoft Internet Explorer

Excellent article from msdn Magazine covering .NET controls in HTML pages with IE: events, params, security, ActiveX comparison.

 

HOW TO: Sink Managed C# Events in Internet Explorer Script

Complete code example.

 

A key security change requires User Control assemblies (any assembly really) to explicitly allow Internet Explorer (an partially trusted caller): Version 1 Security Changes for the Microsoft .NET Framework & KB814669

using System.Security;

[assembly:AllowPartiallyTrustedCallers]

 

Interestingly this article can’t be found on the MSDN online knowledge base but can be found on the support.microsoft.com site (both by kb814669 and by “strong name internet explorer”). Lesson learned, search the support site as well as the msdn site. The date on the article is 2003-04-07 so it sure isn’t on the installed MSDN content.

 

Debugging:

1.      Load a page containing the embedded control into IE.

2.      Go to visual studio Debug?Processes?Attach to the iexplorer.exe process running the page.

3.      Check CLR & script.

 

FUSLOGVW.exe

Tool to display IE object loading errors.

Generates output such as:

*** Assembly Binder Log Entry  (2003-04-27 @ 23:22:24) ***
 
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
 
Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\fusion.dll
Running under executable  C:\Program Files\Internet Explorer\iexplore.exe
--- A detailed error log follows. 
 
=== Pre-bind state information ===
LOG: DisplayName = Upload, Version=1.0.1212.39999, Culture=neutral, PublicKeyToken=4a21a4d0f53ad996
 (Fully-specified)
LOG: Appbase = http://localhost
LOG: Initial PrivatePath = bin
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
 
LOG: Processing DEVPATH.
LOG: DEVPATH is not set. Falling through to regular bind.
LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: Upload, Version=1.0.1212.39999, Culture=neutral, PublicKeyToken=4a21a4d0f53ad996
LOG: Cache Lookup was unsuccessful.
LOG: Attempting download of new URL http://localhost/Upload.DLL.
LOG: Attempting download of new URL http://localhost/Upload/Upload.DLL.
LOG: Attempting download of new URL http://localhost/bin/Upload.DLL.
LOG: Attempting download of new URL http://localhost/bin/Upload/Upload.DLL.
LOG: Attempting download of new URL http://localhost/Upload.EXE.
LOG: Attempting download of new URL http://localhost/Upload/Upload.EXE.
LOG: Attempting download of new URL http://localhost/bin/Upload.EXE.
LOG: Attempting download of new URL http://localhost/bin/Upload/Upload.EXE.
LOG: All probing URLs attempted and failed.

 

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)