is there a way to reference a dll and it's events in c#?

dynamic_sysop

Well-known member
Joined
Oct 1, 2002
Messages
1,039
Location
Ashby, Leicestershire.
i have a dll which i use in vb.net without a problem , but i want to try it in c#, ive added a reference , then at the top of the form got...
using SOCK; //this is the name of the dll.
then ive 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.
 
i tried this...
Code:
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
 
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 its members are static. Then you use this to access the instance of the new SOCK object you just created.
Ex:
C#:
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
      }
   }
}
 
cheers for the reply , im nearly there but i get this:
Code:
			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:-\
 
to elaberate further , this is the error message im getting
Code:
: Method WindowsApplication3.Form1.On_Connect(object, SOCK.__Socket_OnConnectEventHandler) does not match delegate void SOCK.__Socket_OnConnectEventHandler()
 
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.
 
You can use your object browser to find the delegate type and see exactly what your method signature should be.
 
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 im not sure if it will run.
 
nope but i did this:
Code:
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:
Code:
socket.Connect("remote host here" , "remote port here");
 
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 dont know VB syntax well enouph.
string s="Hi";
socket.Connect(ref s, "remote port here");
 
Back
Top