Leaders dynamic_sysop Posted June 5, 2003 Leaders Posted June 5, 2003 i have a dll which i use in vb.net without a problem , but i want to try it in c#, i've added a reference , then at the top of the form got... using SOCK; //this is the name of the dll. then i've tried ... this.SOCK // but it doesnt do anything any advice on how i can reference my dll and get it to actually do something would be great ty. Quote
*Experts* mutant Posted June 5, 2003 *Experts* Posted June 5, 2003 DId you declare any of the classes or objects from the DLL? Quote
Leaders dynamic_sysop Posted June 5, 2003 Author Leaders Posted June 5, 2003 i tried this... using SOCK; /// this.On_Connect += new SOCK.__Socket_OnConnectEventHandler(this.On_Connect); /// highlights this >>> this.On_Connect <<< /// private void On_Connect(object sender, SOCK.__Socket_OnConnectEventHandler e) { } i cant get it to do "this.SOCK" etc Quote
aewarnick Posted June 6, 2003 Posted June 6, 2003 Did you try it without the "this" referece? To use this you need to create an instance of a class SOCK before you can use it, unless it's members are static. Then you use this to access the instance of the new SOCK object you just created. Ex: TheNamespace { public class TheClass : Form { SOCK sock; // Member of the class- new SOCK instance public TheClass() // Constructor { this.sock = new SOCK(); // Initialize the sock instance this.sock.TheListShouldPopUpHere // Now you can use it } } } Quote C#
Leaders dynamic_sysop Posted June 6, 2003 Author Leaders Posted June 6, 2003 cheers for the reply , i'm nearly there but i get this: this.socket = new SOCK.SocketClass(); this.socket.OnConnect += new SOCK.__Socket_OnConnectEventHandler (this.On_Connect); /// this i have in the designer area /// this line >> this.On_Connect << gets highlighted still /// /// this is my code in the form... private void On_Connect(object sender, SOCK.__Socket_OnConnectEventHandler e) { } no matter how i change it always the same line gets highlighted:-\ Quote
Leaders dynamic_sysop Posted June 6, 2003 Author Leaders Posted June 6, 2003 to elaberate further , this is the error message i'm getting : Method 'WindowsApplication3.Form1.On_Connect(object, SOCK.__Socket_OnConnectEventHandler)' does not match delegate 'void SOCK.__Socket_OnConnectEventHandler()' Quote
aewarnick Posted June 6, 2003 Posted June 6, 2003 Private void On_Connect(Object sender, SOCK.__Socket_OnConnectEventHandler e) {} The argument in bold is wrong. There should be some kind of EventArgs argument not EventHandler. Quote C#
*Gurus* divil Posted June 6, 2003 *Gurus* Posted June 6, 2003 You can use your object browser to find the delegate type and see exactly what your method signature should be. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Leaders dynamic_sysop Posted June 6, 2003 Author Leaders Posted June 6, 2003 cheers divil, i found this: public sealed delegate __Socket_OnConnectEventHandler : System.MulticastDelegate Member of SOCK but no matter how i impliment it nothing matters it still throws an error. so i'm not sure if it will run. Quote
aewarnick Posted June 6, 2003 Posted June 6, 2003 Did you find anything that had to do with an EventArgs argument Quote C#
Leaders dynamic_sysop Posted June 6, 2003 Author Leaders Posted June 6, 2003 nope but i did this: this.socket.OnConnect += new SOCK.__Socket_OnConnectEventHandler (this.OnConnect()); /// private void OnConnect() { } that stops an error showing, but when i send OnConnect(); from a button and try to connect my socket it says cannot change ref object to string :-\ it should do this: socket.Connect("remote host here" , "remote port here"); Quote
aewarnick Posted June 6, 2003 Posted June 6, 2003 Apparently, the parameter is a reference to an object, so create a variable and pass that variable by reference to the sub. C# code for this, I don't know VB syntax well enouph. string s="Hi"; socket.Connect(ref s, "remote port here"); Quote C#
Leaders dynamic_sysop Posted June 7, 2003 Author Leaders Posted June 7, 2003 thanks for the help on this , the dll is not working correctly , i've tried a winsock dll and that works how it should so there's something wrong with the dll i was using i think. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.