c# - Code Written for .NET 4 returning Error For .NET 3.5 Client -


i trying take library coded .net 4 , recompile use .net 3.5 client. library available @ https://github.com/cshivers/ircclient-csharp/tree/master/ircclient-csharp

this block of code in program gets error when calling irc.channelmessage in external library.

  private sub irc_channelmessage(channel string, user string, message string) handles irc.channelmessage         rtboutput.clear()         rtboutput.text = message         if rtboutput.text.startswith("!listen ")             dim s string = rtboutput.text             dim pars new list(of string)(s.split(" "c))              checkparams(pars)         end if     end sub 

the library works program when set use .net 4, when set use .net 3.5 client returns error below

error 4 method 'private sub irc_channelmessage(channel string, user string, message string)' cannot handle event 'public event channelmessage(sender object, e techlifeforum.channelmessageeventargs)' because not have compatible signature.

it seems once compile .net 3.5 ircclient.cs can't translate eventarguments.cs properly...

in ircclient.cs calling

 public event eventhandler<channelmessageeventargs> channelmessage = delegate { }; 

and should call eventarguments.cs:

public class channelmessageeventargs : eventargs     {         public string channel { get; internal set; }         public string { get; internal set; }         public string message { get; internal set; }         public channelmessageeventargs(string channel, string from, string message)         {             this.channel = channel;             this.from = from;             this.message = message;         }     } 

however work in .net 4 ideas?

when setting event handler (handles keyword), signature of method (in other words, variables passed method) must match signature of event.

your event's signature (c#):

eventhandler<channelmessageeventargs> channelmessage 

(vb.net):

eventhandler(eventargs channelmessageeventargs) 

you incorrectly trying handle event following signature:

irc_channelmessage(channel string, user string, message string) 

these 3 variables contained within channelmessageeventargs class, , passed together, therefore can change event handling method to:

private sub irc_channelmessage(eventargs channelmessageeventargs) handles irc.channelmessage     rtboutput.clear()     rtboutput.text = eventargs.message     if rtboutput.text.startswith("!listen ")         dim s string = rtboutput.text         dim pars new list(of string)(s.split(" "c))          checkparams(pars)     end if end sub 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -