cannot implicitly convert type System.EventHandler .NET

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
 
D

Dmitriy Lapshin [C# / .NET MVP]

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.
 
T

Terminal882003

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top