473,416 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Consuming managed events within Internet Explorer

Hello and thank you in advance for your help.

Can anyone think of a reason why this code would work properly on one PC,
but not another?

I've got a System.Windows.Forms.UserControl that products events which I
want to consume (sink) within Internet Explorer.

I'm following the instructions at:
ms-http://support.microsoft.com/default.aspx?kbid=313891.

On one computer, Internet Explorer can call methods on the UserControl and
can sink events generated by this managed code.

Using the same code on another computer, Internet Explorer can call methods
on this UserControl, but can not sink the events this managed code is
generating.

The UserControl is written in Visual Studio 2003 using C#. The framework
version is "v1.1.4322" on both computers.

The operating system on the computer where the code works (call methods on
the UserControl + sink events generated by the UserControl in IE) is: XP sp2
+ all the latest Windows Updates.

The operating system on the computer where the code does NOT work (call
methods on the UserControl only) is: XP sp1 + all the latest Windows Updates.

Here's a copy of the C# UserControl code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace TestWUCEventer
{
#region EventDelegates

/// <summary>
/// Delegate invoked when a NOTIFY event occurs.
/// </summary>
public delegate void sssNotifyEventHandler(string getResultXml);

/// <summary>
/// Delegate invoked when a SURVEY event occurs.
/// </summary>
public delegate void sssSurveyEventHandler();

#endregion

#region Outgoing COM Interfaces

/// <summary>
/// This interface is for raising SDK events to COM clients.
/// </summary>
[GuidAttribute("4AF6A157-AD81-4da3-8FF7-1AD1135D0645")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIDispatch)]
public interface ISDKEvents
{
/// <summary>
/// Raise the NOTIFY event to COM clients.
/// </summary>
/// <param name="getResultXml">The string that is passed with the NOTIFY
event.</param>
[DispIdAttribute(0x60020010)]
void NotifyEvent(string getResultXml);

/// <summary>
/// Raise a SURVEY event to COM clients.
/// </summary>
[DispIdAttribute(0x60020011)]
void SurveyEvent();
}

#endregion

#region Incomming COM Interfaces

public interface ISDKClient
{
/// <summary>
/// Raise the NOTIFY event.
/// </summary>
/// <param name="IncludeWithNotify">Data passed with the NOTIFY
event.</param>
void RaiseNotifyEvent(string IncludeWithNotify);

/// <summary>
/// Raise the SURVEY event.
/// </summary>
void RaiseSurveyEvent();

/// <summary>
/// Simple test for accessing Windows Control Library method from web page
displayed in IE.
/// </summary>
/// <returns>Hello World</returns>
string TestMessage();

/// <summary>
/// Start the timer which automatically raises events.
/// </summary>
void StartTimer();
}

#endregion

/// <summary>
/// Summary description for UserControl1.
/// </summary>
[ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(ISDKEvents))]
public class EventGenerator : System.Windows.Forms.UserControl, ISDKClient
{
#region EventsRaised

/// <summary>
/// Event is raised when a SURVEY occurs.
/// </summary>
public event sssSurveyEventHandler SurveyEvent;

/// <summary>
/// Event raised when a NOTIFY occurs.
/// </summary>
public event sssNotifyEventHandler NotifyEvent;

#endregion

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Timer eventTimer = null;
private enum EventType { SURVEY, NOTIFY };
private EventType lastEvent = EventType.SURVEY;

public EventGenerator()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();

// TODO: Add any initialization after the InitComponent call

// Start our eventTimer.
eventTimer = new Timer();
eventTimer.Tick += new EventHandler(eventTimer_Tick);
eventTimer.Interval = 2000;
eventTimer.Enabled = false;
// eventTimer.Start();
}

/// <summary>
/// Start a timer that automatically raises events.
/// </summary>
public void StartTimer()
{
eventTimer.Enabled = true;
eventTimer.Start();
}

/// <summary>
/// Simple test for accessing Windows Control Library method from web page
displayed in IE.
/// </summary>
public string TestMessage()
{
return ("Hello World");
}

/// <summary>
/// Call RaiseNotifyEvent to cause a NOTIFY event to be raised.
/// </summary>
/// <param name="IncludeWithNotify">Any string to include as the data of
the NOTIFY event.</param>
public void RaiseNotifyEvent(string IncludeWithNotify)
{
try
{
if (NotifyEvent != null)
{
NotifyEvent(IncludeWithNotify);
}
}
catch (Exception exc)
{
throw (exc);
}
}

/// <summary>
/// Call RaiseSurveyEvent to cause a SURVEY event to be raised.
/// </summary>
public void RaiseSurveyEvent()
{
try
{
if (SurveyEvent != null)
SurveyEvent();
}
catch (Exception exc)
{
throw (exc);
}
}

private void eventTimer_Tick(object sender, EventArgs e)
{
// Stop the timer until we're done with this method.
eventTimer.Stop();

if (lastEvent == EventType.SURVEY)
{
// Raise a NOTIFY event.
RaiseNotifyEvent("This is a test string.");

// Record the last event raised.
lastEvent = EventType.NOTIFY;
}
else
{
// Raise a NOTIFY event.
RaiseSurveyEvent();

// Record the last event raised.
lastEvent = EventType.SURVEY;
}

// Start the timer again.
eventTimer.Start();
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// EventGenerator
//
this.Name = "EventGenerator";
this.Size = new System.Drawing.Size(1, 1);

}
#endregion

}
}

Here's a copy of the web page that runs in Internet Explorer:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
Inherits="EventTesterWeb.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" id="SurveyEventHandler" event="SurveyEvent"
for="ssClient">
alert("SURVEY event");
</script>
<script language="javascript" id="NotifyEventHandler"
event="NotifyEvent(notifyResultXml)" for="ssClient">
alert("NOTIFY event: " + notifyResultXml);
</script>
<script id="WebPageScript" language="javascript">
function OnWebPageLoad()
{
// Try calling the test method.
document.all.lblDisplayMessage.outerText = ssClient.TestMessage();
}
function StartTimer()
{
ssClient.StartTimer();
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" onload="javascript:OnWebPageLoad();">
<OBJECT id="ssClient"
classid="http:TestWUCEventer.dll#TestWUCEventer.Ev entGenerator" height="32"
width="32">
</OBJECT>
<form id="Form1" method="post" runat="server">
<asp:Label id="lblDisplayMessage" style="Z-INDEX: 101; LEFT: 8px;
POSITION: absolute; TOP: 8px"
runat="server" Width="240px">Nothing yet...</asp:Label>
<input type="button" value="Start Timer"
onclick="javascript:StartTimer();" />
</form>
</body>
</HTML>

Apr 17 '06 #1
1 3491
Have you compared the Internet Explorer security settings on the two
machines? You may find the one that doesn't work is due to a security
restriction or setting which isn't in force on the machine where your
code does work.

Other than that, try making sure the platforms are as similar as
possible - it could be an SP2 / SP1 thing.

Cheers, M

Apr 18 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
3
by: Rick Strahl [MVP] | last post by:
I'm working on an app that's using the WebBrowser control. I got the control working fine, hooking to the document object. But I've run into a major issue with hooking the Document events....
0
by: Kerem Gümrükcü | last post by:
Hi, i use the internet explorer embeeded in SHDocVw.dll but my WebBrowser Object does not fire any event. is this a Bug and how can i "receive" events from my Browser class...? Everything...
5
by: | last post by:
I'm having difficulty embedding a managed C++ control in Internet Explorer. I'm using the same object syntax in the html as I would for a c# control, but IE doesn't seem to find the control in the...
7
by: Roberto Perez via .NET 247 | last post by:
Hello all and thank you in advance. We have several old applications in Cobol, Centura, etc that needs to be converted to .NET In order to save time our plan is to create web services and call...
7
by: mfeingold | last post by:
I am working on a system, which among other things includes a server and a ..net control sitting in an html page and connected to the server. I ran into a couple of problems, you guys might have...
2
by: niels.froehling | last post by:
Hy; I'm stucked in modifying events to make a multi-select select-input being additive/subtractive only. Because I should offer a solution similar to that select for DAUs (aka. MostIdioticUser)...
2
by: Filippo Bettinaglio | last post by:
Hi, I use, VS2005 C# I have a Windows Forms UserControl hosted within Internet Explorer According to MIcrosoft documentation: ...
0
by: jonathan.beckett | last post by:
I have been working on a client project recently that is using winforms ..NET user controls within web pages in Internet Explorer, and need to find out how to make the user control communicate back...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.