[Fwd: Re: [Mono-list] calling library functions]
Mario Munda
mario.munda at amis.net
Fri Jan 27 08:38:15 EST 2006
Bradley, Peter wrote:
> Your namespace is:
>
> MyFuncs.Net
>
> The compiler is looking for:
>
> funcs.net
>
> Also your class is called winsock, but the compiler is looking for a
> class called msocket.
>
> Main.cs(100,5): error CS0117: `funcs.net.msocket' does not contain a
> definition for `SendData'
> Compilation failed: 1 error(s), 0 warnings
>
> Would that be it?
>
>
> Peter
>
>
> -----Original Message-----
> From: mono-list-bounces at lists.ximian.com
> [mailto:mono-list-bounces at lists.ximian.com] On Behalf Of Mario Munda
> Sent: 27 January 2006 13:19
> To: Jonathan Pryor
> Cc: mono-list at lists.ximian.com
> Subject: Re: [Mono-list] calling library functions
>
> 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,So
> cketFlags.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 - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>
>
>
>
Hi!
I found the problem.
I guess class name winsock is reserved!
I changed my class name from winsock to vinsock, compiled, and it works ok!
Thanks for help to everyone!
More information about the Mono-list
mailing list