Why do you assume that there is a bad consequence if g_set_prgname() is not called? Please test it, and if you confirm any bad behaviour, come back with more info.

On 03/11/13 20:50, Vardar Sahin wrote:
I think that GLib.Global.ProgramName has to be set to a value.I am not
sure what will happen when it is not set.
In case args == null and we should set GLib.Global.ProgramName to a
static value like this.

var args = Environment.GetCommandLineArgs ();
if (args != null && args.Length > 0){
     GLib.Global.ProgramName =
System.IO.Path.GetFileNameWithoutExtension (args [0]);
}else
{
    GLib.Global.ProgramName = "EmbeddedMono";
}


2013/11/3 "Andrés G. Aragoneses" <kno...@gmail.com
<mailto:kno...@gmail.com>>

    On 03/11/13 15:58, Vardar Sahin wrote:

        Environment.GetCommandLineArgs is an internal call and my
        assumption was
        that the internal call is not registered to a C function. But
        now I see
        that I can call Environment.__GetCommandLineArgs.
        I checked it out and Environment.GetCommandLineArgs returns null
        if you
        embed mono into your application.

        So you have to check for a null reference.


    Ok thanks, I updated the pull request adding a null check



        And and maybe you have to set
        GLib.Global.ProgramName to static name in case.


    What do you mean? GLib.Global.ProgramName is already static.

    Thanks




        2013/11/2 "Andrés G. Aragoneses" <kno...@gmail.com
        <mailto:kno...@gmail.com>
        <mailto:kno...@gmail.com <mailto:kno...@gmail.com>>>


             Being not registered means that accessing
        GetCommandLineArgs throws
             an exception? If yes, what kind?


             On 02/11/13 22:10, Vardar Sahin wrote:

                 Hey Andrés,

                 thanks for the quick replay. I am not sure if this will
        fix the
                 problem.
                 I think the problem is that you can not call
                 Environment.____GetCommandLineArgs() when you embed mono.
                 Environment.____GetCommandLineArgs() is an internal
        call and it

                 seems like
                 it is not registered when you embed mono.

                 Best
                 Sahin




                 2013/11/2 "Andrés G. Aragoneses" <kno...@gmail.com
        <mailto:kno...@gmail.com>
                 <mailto:kno...@gmail.com <mailto:kno...@gmail.com>>
                 <mailto:kno...@gmail.com <mailto:kno...@gmail.com>
        <mailto:kno...@gmail.com <mailto:kno...@gmail.com>>>>



                      On 02/11/13 21:42, Vardar Sahin wrote:

                          Hey monodev fellows,

                          first of all I appreciate all your hard work
        and want to
                          contribute this
                          to the mono project.

                          Right now it is not possible to use GTK# with an
                 application which
                          embeds mono. GTK# works just fine if you use
        mono as a
                 standalone
                          application eg mono.exe.

                          The reason why GTK# does not works when you
        embed mono
                 is as
                          fallowing.

                          Each GTK# Application has to call
        Application.Init().

                          This functions is like this.

                          public static void Init ()
                          {
                          SetPrgname ();
                          IntPtr argv = new IntPtr(0);
                          int argc = 0;

                          gtk_init (ref argc, ref argv);


          SynchronizationContext.______SetSynchronizationContext (new
                          GLib.______GLibSynchronizationContext ());}



                          Init will fail on SetPrgname (); when mono is
        embedded
                 in an
                          application.

                          static void SetPrgname ()
                          {
                          GLib.Global.ProgramName =
                          System.IO.Path.______GetFileNameWithoutExtension
                          (Environment.______GetCommandLineArgs () [0]);


                          }

                          When embedding Mono,
        Environment.GetCommandLineArgs ()
                 will fail
                          because
                          it is not set to anything. When you run the
        same on
                 mono as a
                          standalone
                          application it will work because mono will
        pass the
                 command line
                          argument via
        Environment.______GetCommandLineArgs().



                          I fixed it by registering the internal call for
                          Environment.GetCommandLineArgs to my own
        fucntion and
                 return just a
                          dummy string.

                          My suggestion would be to do the same in mono
        when you
                 embed it
                          or to
                          change SetPrgname  to not relay on
                          Environment.GetCommandLineArgs ().


                      Sahin, wouldn't this also fix your use case?

        https://github.com/mono/gtk-______sharp/pull/90/files
        <https://github.com/mono/gtk-____sharp/pull/90/files>
                 <https://github.com/mono/gtk-____sharp/pull/90/files
        <https://github.com/mono/gtk-__sharp/pull/90/files>>


          <https://github.com/mono/gtk-____sharp/pull/90/files
        <https://github.com/mono/gtk-__sharp/pull/90/files>
                 <https://github.com/mono/gtk-__sharp/pull/90/files
        <https://github.com/mono/gtk-sharp/pull/90/files>>>


                      Thanks


                      _____________________________________________________
                      Mono-devel-list mailing list
                      Mono-devel-list@lists.ximian.______com
                      <mailto:Mono-devel-list@lists.
        <mailto:Mono-devel-list@lists.>____ximian.com <http://ximian.com>
                 <mailto:Mono-devel-list@lists.__ximian.com
        <mailto:Mono-devel-list@lists.ximian.com>>>
        http://lists.ximian.com/______mailman/listinfo/mono-devel-______list
        <http://lists.ximian.com/____mailman/listinfo/mono-devel-____list>

        <http://lists.ximian.com/____mailman/listinfo/mono-devel-____list 
<http://lists.ximian.com/__mailman/listinfo/mono-devel-__list>>


        <http://lists.ximian.com/____mailman/listinfo/mono-devel-____list 
<http://lists.ximian.com/__mailman/listinfo/mono-devel-__list>

        <http://lists.ximian.com/__mailman/listinfo/mono-devel-__list
        <http://lists.ximian.com/mailman/listinfo/mono-devel-list>>>






                 ___________________________________________________
                 Mono-devel-list mailing list
                 Mono-devel-list@lists.ximian.____com
                 <mailto:Mono-devel-list@lists.__ximian.com
        <mailto:Mono-devel-list@lists.ximian.com>>
        http://lists.ximian.com/____mailman/listinfo/mono-devel-____list
        <http://lists.ximian.com/__mailman/listinfo/mono-devel-__list>

        <http://lists.ximian.com/__mailman/listinfo/mono-devel-__list
        <http://lists.ximian.com/mailman/listinfo/mono-devel-list>>



             ___________________________________________________
             Mono-devel-list mailing list
             Mono-devel-list@lists.ximian.____com
             <mailto:Mono-devel-list@lists.__ximian.com
        <mailto:Mono-devel-list@lists.ximian.com>>
        http://lists.ximian.com/____mailman/listinfo/mono-devel-____list
        <http://lists.ximian.com/__mailman/listinfo/mono-devel-__list>

        <http://lists.ximian.com/__mailman/listinfo/mono-devel-__list
        <http://lists.ximian.com/mailman/listinfo/mono-devel-list>>




        _________________________________________________
        Mono-devel-list mailing list
        Mono-devel-list@lists.ximian.__com
        <mailto:Mono-devel-list@lists.ximian.com>
        http://lists.ximian.com/__mailman/listinfo/mono-devel-__list
        <http://lists.ximian.com/mailman/listinfo/mono-devel-list>



    _________________________________________________
    Mono-devel-list mailing list
    Mono-devel-list@lists.ximian.__com
    <mailto:Mono-devel-list@lists.ximian.com>
    http://lists.ximian.com/__mailman/listinfo/mono-devel-__list
    <http://lists.ximian.com/mailman/listinfo/mono-devel-list>




_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list



_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to