Re: [Mono-list] P/Invoke, Mono, .NET and Windows XP funny platform

2005-06-13 Thread Francis Brosnan Blázquez

First of all, thanks for your reply. It have been really productive.

Some issues about your reply:


Your fundamental problem is that you're targeting Windows XP.

Ha ha only serious.  (A colloquialism for that's funny, but I'm serious
too...)

The slightly longer explanation is here:


http://www.mono-project.com/Interop_with_Native_Libraries#Windows_DLL_Search_Path

The real explanation is that Win32 is broken when it comes to supporting
multiple different versions of the same library.  Absolutely,
fundamentally, *broken*.  More to the point, it doesn't support this AT
ALL -- you can only have ONE version of any given library in use at any
point in time.

Win32 has three issues you're running into:

1. No built-in versioning support for libraries, as noted above.
   Which is to say, if you load C:\Windows\System32\OLE32.dll, you 
   can't say that you want version 1 or version 2 of that library, 
   you get whichever version is at C:\Windows\System32\OLE32.dll.


2. This doesn't mean you can't have multiple different versions 
   installed.  It just means that each different version needs to 
   reside in a different directory, which leaves you the option of

   (a) always specifying a full (or relative) directory for your
   library, or (b) accepting the default path and placing your library
   into an appropriate location.

   So if you didn't like Microsoft's OLE32.DLL, you could place a copy
   into your application's directory, and *that* one would get loaded.

   Alas, this means you can have the scenario you're describing, where
   both mono and your app bundle glib.  This is unfortunate, because of
   issue (3).

3. Win32 doesn't keep track of the full path name to a library.  It 
   only remembers the basename of the library.


   Translation:  If you LoadLibrary() C:\mono\glib.dll, Win32 will know
   that it's loaded glib.dll.  If you then LoadLibrary() 
   C:\yourapp\glib.dll, Win32 will hand you back a handle to 
   C:\mono\glib.dll, because they both share the same basename 
   (glib.dll) -- C:\yourapp\glib.dll is NOT loaded.


   Win32 doesn't operate on full paths.  This is a feature (in certain 
   contexts, anyway -- it's what allows you to provide your own version

   of OLE32.dll, or any other system library, and have it be used).

So, to answer your questions...

On Thu, 2005-06-09 at 19:23 +0200, Francis Brosnan Blzquez wrote:
 


* Any application which p/invokes libraries that are also provided by
mono must compile its native dll versions against the mono dll or it
is posible to compile these ones against, for example, a glib not
provided by the mono installer?
   



Is it possible?  Yes.  But to use your version of glib and not mono's
version, you'd need to alter the library search order for mono to ensure
it loads your version of glib and not mono's.

This probably is bad, because it will effect every application started
with mono, and your glib might not be compatible with mono's glib, which
would (likely) kill mono instantly.

So it's possible, but it's not advisable. :-)

Plus, it'll use extra disk space, so it would be nicer to use mono's
glib anyway...
 

The space impact that may have including several libraries using 
different names don't
worry us. But setting a dependency against the mono libraries, such as 
libglib-2.0, force
us to run over Mono and only over it. As you pointed following, the 
library renaming
could be a solution to be able to run on top of Mono and microsoft .NET 
runtime.



Alternatively, name your glib.dll with a different basename, e.g. af-
arch-glib.dll, and rebuild all your libraries against this basename.

 


About the library renaming issue.

Renaming library basename could help us to find a solution to build 
application that can run
on top of mono and .NET runtime ensuring the libraries the af-arch 
framework relies on will
allways be loaded using the dll version we have used (appending the 
af-arch-)

on develop stage.

My question is: Could this confuse the windows dinamic library loading 
to load a library
called glib.dll and another one called af-arch-glib.dll both exporting 
the same symbols?


In other words, while running applications using .NET and doing P/Invoke 
over the

af-arch-glib.dll the LoadLibrary will find it with no problem as well the
Mono enviroment will do but, in the case of Mono, it have the glib.dll 
already loaded
exporting the same (or mostly) symbols leading to have loaded into 
memory two

version for the same entry point.

Using as follow [DllImport(af-arch-glib)] will ensure the .NET runtime 
as well as Mono to
load the af-arch-glib.dll library. But will this also guide both 
runtimes to differenciate the symbols

exported from glib.dll and those ones from af-arch-glib.dll?



* What happens if the mono runtime detects a P/Invoke over a library
A.dll which depends on B.dll and then another P/Invoke over the
library C.dll which depends on B'.dll knowing that B.dll and B'.dll
are the same library but 

Re: [Mono-list] Cygwin woes

2004-12-13 Thread Francis Brosnan Blázquez
Hi,

Using Cygwin allows you to compile against cygwin1.dll library or using
mingw interface (-mno-cygiwin) to compile against msvcrt.dll. But, you
can not mix dlls compiled from different method. Check out the cygwin
fac.

What is happening is that your dll test.dll is compiled against
cygwin1.dll (by using the second method) and mono is compiled against
msvcrt.dll.

You can also use objdump -p /path/to/the/binary to see against what dll
is compiled some program.

On windows, if you still want to use cygwin you need to use -mno-cygwin.

.-Francis


-- 
Francis Brosnan Blázquez [EMAIL PROTECTED]

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Re: Calling back from unmanaged code to managed code.

2004-12-11 Thread Francis Brosnan Blázquez
  } 


Conclusion:

1) Maybe this is a mono problem. I'm not agree with this because
implement a general solution will requiere an effort which won't be
corresponded with the functionality gained. 

2) In the case mono support this, I will strongly recommend not to relay
on it because you'll be mono-specific.

3) With this solution you have increased your C-API functionality by
giving it a synchronous version. 

4) with this solution you have an really simple to understand .NET class
api which allows consumer to choose how to invoke it.

5) Finally, think about events. C Asynchronous API only support to
callbacks only one delegate. 

   
[1] Managed and Unmanaged Threading in Microsoft Windows
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconmanagedunmanagedthreadinginmicrosoftwindows.asp

[2] Asynchronous programming overview
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpovrasynchronousprogrammingoverview.asp

[3] Managed and Unmanaged Code Integration
http://www.jprl.com/~jon/interop.html

-- 
Francis Brosnan Blázquez [EMAIL PROTECTED]

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Re: [Gtk-sharp-list] reusing windows using attribute [Widget]

2004-12-09 Thread Francis Brosnan Blázquez
Hi Javier,

Once an window is showed you should catch delete-event and hide it
yourself to avoid the window from being destroyed by the gtk engine.
Thus, you can later show again the window by using window.Show ();

Another approach, which I prefer since we are working in a managed
environment, is to have one class per window with its glade loading
stuff and do nothing for delete-event. Every time you need to launch a
window simply create a new instance.

.-Francis





___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Platform invoke for stdarg

2004-11-16 Thread Francis Brosnan Blázquez
El lun, 15-11-2004 a las 20:54 -0500, Jonathan Pryor escribió:
 On Mon, 2004-11-15 at 20:24 +0100, Francis Brosnan Blázquez wrote:
  Hi,
  
  I'm trying to do a P/Invoke call for functions such as 
  
  void Test(int value, ...); 
  
  But I don't get it working. Is it posible to do a platform invoke for c
  functions that make use of stdarg api?
 
 No, and Maybe. :-)
 
 There is no general way to marshal ... parameters, which requires that
 all the parameters be passed on the stack -- the Cdecl calling
 convention.  The .NET marshaller can only work with a fixed number of
 arguments.
 
 However, there are two solutions:
 
 1.  Standard overloading: If there is a reasonable number of
 parameters you need, you can explicitly specify them as overloads.  I do
 this in Mono.Posix to wrap open(2):
 
   DllImport (libc, CallingConvention=CallingConvention.Cdecl)
   public static extern int open (string pathname, int flags);
 
   DllImport (libc, CallingConvention=CallingConvention.Cdecl)
   public static extern int open (string pathname, int flags, uint mode);
 
 If you plan on using this code on Windows, you *must* specify
 CallingCOnvention.Cdecl, as the default is Stdcall, which doesn't permit
 variable argument lists.
 
 Obviously, this is only viable if you have a limited number of potential
 overloads.  Wrapping printf(3) is impractical, as it could result in
 hundreds (thousands?) of overloads.
 
 2.  Get creative, take an object[] array, and generate some
 System.Reflection.Emit code which accepts the proper number of
 parameters of the proper type, and invoke the recently generated code.
 IIRC cocoa-sharp does something similar to this for its msg_send
 implementation.  Pro: it works for any argument list.  Con: it's not
 easy.
 
This solution sounds good. Thanks for your clear reply!
  - Jon
 
 
 

-- 
Francis Brosnan Blázquez [EMAIL PROTECTED]

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Mono C# bindings index

2004-10-23 Thread Francis Brosnan Blázquez
El vie, 22-10-2004 a las 17:07, Fabien Meghazi escribió:
  Microsoft released their .net wiki under an OSS license and it is
  hosted on sourceforge.
 
 Well, whatever which platform is used for this wiki, perhaps this is
 the good place in order to ask who would accept to participate to this
 project. First of all we need to find where to host this wiki. Someone
 have an idea about that ?

Why not on www.mono-project.com? 

 ___
 Mono-list maillist  -  [EMAIL PROTECTED]
 http://lists.ximian.com/mailman/listinfo/mono-list

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Re: [Gtk-sharp-list] Problem with Gnome.About

2004-10-21 Thread Francis Brosnan Blázquez
Hi Sergio,

If you include images as resources you should try to use:

Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (null, avispa.png);

Cheers.

.-Francis.




___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Where is glib-sharp?

2004-10-16 Thread Francis Brosnan Blázquez
El sáb, 16-10-2004 a las 03:51, Kevin White escribió:
 I am trying to compile the example from
 http://www.gotmono.com/docs/gnome/bindings/gtk-sharp/packingdemonstrationprogram.html
 to learn how to use GTK# and am having a problem.
 
 When I type:
 mcs -pkg:gtk-sharp,glib-sharp -r:System.Drawing packer.cs I get errors
 that the glib-sharp.pc cannot be found (indeed this does not exist on
 my system, though glib-sharp files exist in the gac).
 
 When I type:
 mcs -pkg:gtk-sharp -r:System.Drawing,glib-sharp packer.cs I get errors
 that it cannot find the assembly 'glib-sharp'.
 
 So how do I properly compile an example such as this?  I really want
 to learn gtk# and this site of tutorials has more examples than the
 mono site.  I'm used to winforms programming through vs.net, so this
 will take some getting used to with mono.
 
 Any help is appreciated.
 
Hi Kevin,

I have the same problem when I was trying to compile tomboy a month ago.
Is just a problem of your gtk-sharp version. Try to install the latest
stable version. In my mono install there is no glib-sharp to reference
to, so it must work by using only gtk-sharp reference.

IHIH


 Thanks,
 
 Kevin
 --
 Kevin White
 [EMAIL PROTECTED]
 ___
 Mono-list maillist  -  [EMAIL PROTECTED]
 http://lists.ximian.com/mailman/listinfo/mono-list
-- 
Francis Brosnan Blázquez [EMAIL PROTECTED]
Advanced Software Production Line, S.L.

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Enum problem

2004-10-16 Thread Francis Brosnan Blázquez
Hi.

Working with enumerations I've found an strange behaviour. If you
compile the following source code and run it:

--
using System;

public class EnumTest {

public enum TipoCarga {
Positivo = 1/3,
Negativo = 1 + (1/3),
Neutro   = 1,
}

public static void Main () {
TipoCarga carga;

carga = TipoCarga.Positivo;
Console.WriteLine (carga value is: {0}, carga);

carga = TipoCarga.Neutro;
Console.WriteLine (carga value is: {0}, carga);

carga = TipoCarga.Negativo;
Console.WriteLine (carga value is: {0}, carga);
}
}
--


You get the following output:
carga value is: Positivo
carga value is: Neutro
carga value is: Neutro

That is, on every assignment which uses TipoCarga.Negativo doesn't work.
I've been reading about how enumerations works and seens to be that you
can only use values from byte, sbyte, short, ushort, int, uint, long, or
ulong types but not float or double types which can hold values as 1/3
and 1 + (1/3). 

The odd thing is that assignment for Positivo = 1/3 works perfectly. 

Maybe mcs mustn't allow someone to compile the previous source code?

.- Francis




___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Using the mono jay parser

2004-10-09 Thread Francis Brosnan Blázquez
Hi,

We are developing an application using mono which have to parse
molecular definitions written in Smiles format. We have already use
bison and flex tools to produce scanners and parsers before, so we want
to keep doing the same ;).

We have started to figure out how mono uses the jay modified version to
produce its c# parser but we are having some problems. One problem is
that we don't find how mono produces its scanner. What lexer is mono
using?. The other problem is that we haven't found much documentation on
how to use jay (not how to use lex and yacc languages) to produce a
parser. 

It would be great to have some guidelines to start. Anything will be
appreciated: files to look, ideas, concepts on how to use your modified
jay...

Cheers,

-- 
Francis Brosnan Blázquez [EMAIL PROTECTED]
Advanced Software Production Line, S.L.

___
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list