cannot implicitly convert type System.EventHandler .NET

  • Thread starter Thread starter Terminal882003
  • Start date Start date
T

Terminal882003

Hi,

Here I have a question about MSCommLib. I need to dynamically add
activeX controls that requires run-time license for MSCommLib. The
following is the actual code:

AxMSCommLib.AxMSComm mscomm = new AxMSCommLib.AxMSComm();

string strLicense = "gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj";

System.Reflection.FieldInfo f =
typeof(AxHost).GetField("licenseKey",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
f.SetValue(mscomm, strLicense);

mscomm.OnComm += new MSCommLib.DMSCommEvents_OnCommEventHandler
(this.mscomm_OnComm);

When I compile the above code, I get an error: "Cannot implicitly
convert type 'MSCommLib.DMSCommEvents_OnCommEventHandler' to
'System.EventHandler'".

Any advice about this problem is more than welcome.

Thanks,
Mindy
 
Hi,

Ensure the mscomm.OnComm event indeed has the
MSCommLib.DMSCommEvents_OnCommEventHandler type and that the
this.mscomm_OnComm method has the signature matching the event delegate's
one.
 
Hi Dmitriy,

Thanks for your reply. This is exactly my problem. Please let me know
how to make the mscomm.OnComm event has
MSCommLib.DMSCommEvents_OnCommEventHandler type. I really appreciate
your help.

Mindy

Dmitriy Lapshin said:
Hi,

Ensure the mscomm.OnComm event indeed has the
MSCommLib.DMSCommEvents_OnCommEventHandler type and that the
this.mscomm_OnComm method has the signature matching the event delegate's
one.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Hi,

Here I have a question about MSCommLib. I need to dynamically add
activeX controls that requires run-time license for MSCommLib. The
following is the actual code:

AxMSCommLib.AxMSComm mscomm = new AxMSCommLib.AxMSComm();

string strLicense = "gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj";

System.Reflection.FieldInfo f =
typeof(AxHost).GetField("licenseKey",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
f.SetValue(mscomm, strLicense);

mscomm.OnComm += new MSCommLib.DMSCommEvents_OnCommEventHandler
(this.mscomm_OnComm);

When I compile the above code, I get an error: "Cannot implicitly
convert type 'MSCommLib.DMSCommEvents_OnCommEventHandler' to
'System.EventHandler'".

Any advice about this problem is more than welcome.

Thanks,
Mindy
 
Back
Top