Jump to content
Xtreme .Net Talk

Recommended Posts

  • Leaders
Posted

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.

  • Leaders
Posted

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

Posted

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
     }
  }
}

C#
  • Leaders
Posted

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:-\

  • Leaders
Posted

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()'

Posted

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.

C#
  • Leaders
Posted

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.

  • Leaders
Posted

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");

Posted

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");

C#
  • Leaders
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...