Problem registering for events from WinForms control hosted in IE

Discussion in 'ASP .Net Security' started by Mike, Jan 16, 2009.

  1. Mike

    Mike Guest

    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
     
    Mike, Jan 16, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Helen
    Replies:
    2
    Views:
    4,288
    bruce barker
    Sep 30, 2004
  2. =?Utf-8?B?U2VnZmFobHQ=?=

    Problem with WinForms User Control Hosted in IE

    =?Utf-8?B?U2VnZmFobHQ=?=, Jan 9, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    628
    Steven Cheng[MSFT]
    Jan 13, 2006
  3. Juan T. Llibre
    Replies:
    2
    Views:
    3,914
    =?Utf-8?B?UmljaA==?=
    Dec 16, 2006
  4. Faredoon Irani via .NET 247

    registering events for dynamically declared DataGrids

    Faredoon Irani via .NET 247, Aug 5, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    164
    Faredoon Irani via .NET 247
    Aug 5, 2004
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    372
    Chris
    Aug 30, 2005
Loading...

Share This Page