|
|
|
|||||
|
Mono 1.2.6 and Ice
Hi,
I have updated Mono on my machine (running Gentoo) to version 1.2.6 and executing my application (wich is using Ice) returns this exception: Code:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at IceInternal.Network.fdToString (System.Net.Sockets.Socket socket) [0x00000] at IceInternal.TcpTransceiver..ctor (IceInternal.Instance instance, System.Net.Sockets.Socket fd) [0x00000] at IceInternal.TcpConnector.connect (Int32 timeout) [0x00000] at IceInternal.OutgoingConnectionFactory.create (IceInternal.EndpointI[] endpts, Boolean hasMore, Boolean threadPerConnection, System.Boolean& compress) [0x00000] at IceInternal.RoutableReference.createConnection (IceInternal.EndpointI[] allEndpoints, System.Boolean& comp) [0x00000] at IceInternal.DirectReference.getConnection (System.Boolean& comp) [0x00000] at Ice.ObjectDelM_.setup (IceInternal.Reference rf) [0x00000] at Ice.ObjectPrxHelperBase.getDelegate__ () [0x00000] at Ice.LocatorPrxHelper.findObjectById (Ice.Identity id, Ice.Context context__, Boolean explicitContext__) [0x00000] at Ice.LocatorPrxHelper.findObjectById (Ice.Identity id) [0x00000] at IceInternal.LocatorInfo.getEndpoints (IceInternal.IndirectReference ref, Int32 ttl, System.Boolean& cached) [0x00000] at Ice.ObjectAdapterI.isLocal (ObjectPrx proxy) [0x00000] at IceInternal.ObjectAdapterFactory.findObjectAdapter (ObjectPrx proxy) [0x00000] at Ice.ObjectPrxHelperBase.getDelegate__ () [0x00000] at Ice.ObjectPrxHelperBase.ice_isA (System.String id__, Ice.Context context__, Boolean explicitContext__) [0x00000] at Ice.ObjectPrxHelperBase.ice_isA (System.String id__) [0x00000] at IceGrid.QueryPrxHelper.checkedCast (ObjectPrx b) [0x00000]
__________________
Michal Kovac student, Charles University, Prague (Logic on Faculty of Philosophy & Arts and Computer Science on Faculty of Mathematics and Physics) project Ferda |
|
|||||
|
The same icecs.dll for Windows and Linux
thank you.
But I don't like the fix. I would like to use the same icecs.dll on both Linux and Windows in my application. so I don't like this: #if __MonoCS__ I found that you use it only in src\Ice\Application.cs. Can you remove it? I use Mono also on Windows so it is not the right swich and such switches should be done at runtime not at compilation time. You can for example define the methods twice in different classes with the same interface and at runtime check the platform... thanks
__________________
Michal Kovac student, Charles University, Prague (Logic on Faculty of Philosophy & Arts and Computer Science on Faculty of Mathematics and Physics) project Ferda |
|
||||||
|
Quote:
Quote:
Quote:
Quote:
Cheers, Michi. |
|
|||||
|
Quote:
CodeProject: Late binding on native DLLs with C#. Free source code and programming articles |
|
|||||
|
DllImport loads the library at runtime
It is true that the DllImport "requires the library name to be hardwired into the code at compile time", but the DllImport loads the library first time the method is called! So if you have in the code methods with the DllImport attribute for both linux and windows and you call only these which are in actual platform everything works.
__________________
Michal Kovac student, Charles University, Prague (Logic on Faculty of Philosophy & Arts and Computer Science on Faculty of Mathematics and Physics) project Ferda Last edited by kovacm : 12-18-2007 at 07:27 PM. Reason: small fix |
|
||||||
|
Thanks for the top. The following works:
Code:
[DllImport("wsock32.dll", EntryPoint="getsockname")]
private static extern int getsocknameWin(IntPtr s, ref sockaddr name, ref int namelen);
[DllImport("libc.so.6", EntryPoint="getsockname")]
private static extern int getsocknameMono(IntPtr s, ref sockaddr name, ref int namelen);
This is a little better than #if __MonoCS__, but still has the disadvantage of hard-wiring the name of the C library. And, due to the limitations of the C# preprocessor, we cannot define the name of the library in the makefile and then substitute it into the code. As far as I can see, the only way to use a DllImport attribute is to have the name of the library as a string literal in the program text Cheers, Michi. |
|
|||||
|
library
Read Interop with Native Libraries - Mono. You can specify only a name without sufixes and prefixes, so if I uderstand correctly this is the right way for the libc.so.6:
Code:
[DllImport("c", EntryPoint="getsockname")]
private static extern int getsocknameMono(IntPtr s, ref sockaddr name, ref int namelen);
__________________
Michal Kovac student, Charles University, Prague (Logic on Faculty of Philosophy & Arts and Computer Science on Faculty of Mathematics and Physics) project Ferda |
|
|||||
|
Ps
And getsocknameGnu or getsocknameUnix (the same name as in System.PlatformID enumeration) is better name for that method, because if you are running Mono on windows this method should not be called.
__________________
Michal Kovac student, Charles University, Prague (Logic on Faculty of Philosophy & Arts and Computer Science on Faculty of Mathematics and Physics) project Ferda |
|
|||||
|
When do you plan to release new version with the fix? (support for mono 1.2.6 + one .dll for both windows and unix)
thanks, Michal
__________________
Michal Kovac student, Charles University, Prague (Logic on Faculty of Philosophy & Arts and Computer Science on Faculty of Mathematics and Physics) project Ferda |
|
|||||
|
Quote:
Regarding the issue at hand - Mono duplicating a .NET bug/deficiency, I ran your test code which I found on Google, where you demonstrated that a non-blocking socket will have null endpoint properties even if the Poll succeeded: Sockets and non-blocking connect - .NET C# I then added a simple Bind call with unspecified address and port -- s.Bind(new IPEndPoint(IPAddress.Any, 0)); -- before calling connect, and then both local and remote endpoints were not null. Could that work for you? Karl |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| icecs.dll and Mono | kwaclaw | Comments | 1 | 11-15-2007 07:28 PM |
| Mono and IceSSL Status | tkrieger | Help Center | 6 | 11-10-2006 08:29 AM |
| IcePack + Debian Linux + Mono + NoEndpointException | kovacm | Bug Reports | 10 | 07-20-2005 06:29 AM |
| Problems compiling IceCS with mono on Fedora Core 3 | iostream | Help Center | 5 | 12-10-2004 05:52 PM |
| mono c# on win32 | panic | Help Center | 5 | 12-13-2003 07:14 PM |