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