PC Review


Reply
Thread Tools Rate Thread

Can't trap event from WinForms control hosted in IE

 
 
Mike
Guest
Posts: n/a
 
      14th Jan 2009
I've had a WinForms control hosted in IE for quite some time now and
it has always worked well (.NET 2.0, IE 7). But recently as we are
preparing for a new release my script tags (e.g. <script for=> that
register for the controls events no longer seem to work. I've never
had a problem with this before and none of the code related to this
has changed since the last release. So when my events fire, there are
no subscribers and nothing happens. Here is a stripped down version of
what I am doing:

[Guid("4DC1846A-197B-48fe-880A-AB59DB5C1226")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IMyEvents
{
[DispId(0x60020002)]
void EventOne(string arg1, string arg2);
}


[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(IMyEvents))]
public partial class MyClass : UserControl
{
public delegate void EventOneDelegate(string arg1, string
arg2);


[Browsable(true)]
public event EventOneDelegate EventOne;

private MyInternalFunc()
{
// this is always "null"
if (EventOne != null)
EventOne("hello", "world");
}

// etc


Finally the HTML and script tag:

<object id="myControl" classid="MyAssembly.dll#MyClass">
<param name ="Param1" value ="foo" />
<param name ="Param2" value ="bar" />
</object>

<script for="myControl" event="EventOne(string arg1, string
arg2)">
alert('Hooray!');
</script>

Here is my IE setup:

-The assembly is signed
-page is in Trusted Sites Zone
-in .NET 2.0 config, Trusted Sites has "Full Trust" permissions (I had
less permissions before, but I ramped them up to try to root out the
issue)
-"Download signed activeX controls" - Enable
-"Initialize and Script controls not marked safe for scripting" -
Enabled
-"Run ActiveX controls and plugins" - Enabled
-"Script ActiveX controls marked safe for scripting" - Enabled
-There are no javascript errors on the page when it is loaded

I'm a bit stumped on why the script tag is not registering for the
event. Again, this has worked flawlessly for a while now.

"What changed?" you ask? The only thing I can tell is that the
assembly with my control has more classes in it now, and the assembly
is now marked as "ComVisible" in AssemblyInfo.cs, whereas it was not
before. I have changed ComVisible to no avail.

There is precisous little info on the net for this particular problem,
especially since the control loads and runs fine, minus the events
issue.

Help appreciated
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE hosted Winforms control. How to prevent font substitution? Pradeep Microsoft Dot NET Framework Forms 1 24th Apr 2006 02:23 AM
Problem with WinForms User Control Hosted in IE =?Utf-8?B?U2VnZmFobHQ=?= Microsoft ASP .NET 5 13th Jan 2006 09:51 AM
Hosted Winforms control in Internet Explorer =?Utf-8?B?UnVzcyBDLg==?= Microsoft Dot NET Framework Forms 2 21st Nov 2005 10:09 AM
IE Hosted WinForms Control will not Download on XP Home Shane Holder Microsoft Dot NET Framework Forms 1 16th Aug 2005 04:21 PM
Re: Webclient.UploadFile problem in IE hosted WinForms control Natty Gur Microsoft Dot NET Framework 0 9th Jul 2004 05:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:32 PM.