Jonathan Pryor wrote:
On Fri, 2006-01-27 at 12:21 +0100, Mario Munda wrote:
I wrote library with cca 10 functions, and they all work ok, but one.
Declaration in library (mlibr.dll):
public void SendData(string Data,string RemoteIP,ushort RemotePort)
{
//
}
Call in Main (Main.exe):
object.Bind(); - compile ok
object.SendData(); - compile error
Is that how you're actually invoking SendData()? That doesn't match the
above declaration; you'd instead need to call it like this:
object.SendData ("data", "remote-ip", (ushort) remotePort);
If that's not it, it would help if you could provide more source code,
narrowing it down to the smallest amount code necessary to generate the
compiler error.
- Jon
This is a part of a source code i have:
using System;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace MyFuncs.Net
{
public class winsock {
public void Bind()
{
// Connect
sIP = Dns.Resolve(Dns.GetHostName()).AddressList[0];
LocalEP = new IPEndPoint(sIP,usLocalPort);
sSocket = new
Socket(AddressFamily.InterNetwork,SocketType.Dgram,ProtocolType.Udp);
try
{
sSocket.Bind(LocalEP);
}
catch(SocketException e)
{
ErrHandler eErrHandler = new ErrHandler();
eErrHandler.ErrClass = e.Source;
eErrHandler.ErrFunc = e.TargetSite.ToString();
eErrHandler.ErrNum = 1;
eErrHandler.ErrDesc = e.Message;
Error(this,eErrHandler);
}
sIP = System.Net.IPAddress.Parse(sRemoteIP);
RemoteEP = new IPEndPoint(sIP,usRemotePort);
try
{
sSocket.Connect(RemoteEP);
}
catch(SocketException e)
{
ErrHandler eErrHandler = new ErrHandler();
eErrHandler.ErrClass = e.Source;
eErrHandler.ErrFunc = e.TargetSite.ToString();
eErrHandler.ErrNum = e.ErrorCode;
eErrHandler.ErrDesc = e.Message;
Error(this,eErrHandler);
}
StateObject stateObject = new StateObject(16,sSocket);
IAsyncResult asyncReceive =
sSocket.BeginReceive(stateObject.sBuffer,0,stateObject.sBuffer.Length,SocketFlags.None,new
AsyncCallback(receiveCallback),stateObject);
}
public void SendData(string Data,string RemoteIP,ushort RemotePort)
{
IPAddress sIP = System.Net.IPAddress.Parse(RemoteIP);
IPEndPoint RemoteEP = new IPEndPoint(sIP,RemotePort);
sSocket.SendTo(System.Text.Encoding.ASCII.GetBytes(Data),RemoteEP);
}
}
}
class Something()
{
public static void Main(string[] args)
{
winsock Winsock = new winsock(LOCAL_PORT,TS_IP,TS_PORT);
Winsock.Bind();
Winsock.SendData("Something","192.168.0.50",7200);
}
}
I didn't include variable and delegate declarations in this email.
Classes winsock and Something are in separate files, winsock was
compiled as -target:library, exe using -r:winsock.
There's also something strange about winsock compilation procedure,
because when i compile: mcs winsock.cs -target:library -warn:1, msgbox
accure with text: the application or dll is not a valid windows image.
I guess, windows try to run this file, after compilation, because there
is no msgbox under freebsd...
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list