tags:

views:

69

answers:

1

I have an InteropUserControl in a .NET assembly that works fine in other operating systems such as Windows XP and Windows 2000. My company sells hardware along with the software we develop, and we get different types of all-in-one touchscreen workstations. Some All of one particular brand installed with Windows Embedded for Point of Sale are demonstrating a strange problem.

On the InteropUserControl, I expose an event in this way:

[ComVisible( true )]
[Guid( OrdCtl.EventsId )]
[InterfaceType( ComInterfaceType.InterfaceIsIDispatch )]
public interface __IControlEvents {
    [DispId( 1 )]
    void ItemSelected( int someid1, int someid2 );
}

And the event delegate and main control (including raising the event) look like this:

[ComVisible( false )]
public delegate void ItemSelectedEventHandler( int someid1, int someid2 );

[Guid( MyControl.ClassId )]
[ClassInterface( ClassInterfaceType.None )]
[ComSourceInterfaces( "MyInteropControl.__IControlEvents" )]
[ComClass( MyControl.ClassId, MyControl.InterfaceId, MyControl.EventsId )]
public partial class MyControl : UserControl, _IMyControl {
    public const string ClassId = "... guid ...";
    public const string InterfaceId = "... guid ...";
    public const string EventsId = "... guid ...";

    public event ItemSelectedEventHandler ItemSelected;

    void OnItemSelected( int someid1, int someid2 ) {
        var del = this.ItemSelected;

        if ( del != null ) {
            del( someid1, someid2 );
        }
    }

    ...
}

This control is used in a VB6 app, and the event handler there is also as one would expect:

Private Sub MyControl_ItemSelected(ByVal someid1 As Long, ByVal someid2 As Long)
    'react to item selection event
End Sub

However, on the machine's demonstrating incorrect behavior, the ItemSelected event is null in the control's code, and so can't be raised. So I know when it won't work and could use a workaround instead.

The event works correctly on Windows XP and Windows 2000, with .NET 2.0 Framework or .NET 3.5 Framework (the project targets 2.0). I had one XP machine demonstrating the same behavior but it had a wonky installation of .NET 3.5. Reinstalling .NET fixed that machine. I thought that was the cause, so I decided to reinstall on the faulty machines.

On one of the faulty machines with Embedded for POS, I ran the 2.0 setup (OS not supported by the 3.5) and selected Repair. This did not fix the problem. Tomorrow morning I plan to try an actual uninstall and reinstall, just to be sure. Some of the machines with this OS work fine, some do not. I suspect the tech who did the setup of these machines did something different on this most recent batch of machines. The information I was given is wrong. I checked myself and all machines with this strange version of Windows are demonstrating the same problem.

What probably (or even just possible) causes could be at fault for the event not getting 'wired up' correctly through the COM-callable wrapper? Added: How might I get it to work on Windows Embedded for Point of Sale?

I'm also taking suggestions for workarounds, hoping to hear one that sounds decent.

A: 

It turns out that there is a Service Pack 3 for WEPOS. After installing this, .NET Framework 3.5 would install. After installing that, the event worked fine.

The Lesson: Make sure everything is up-to-date.

Joel B Fant