[Freeswitch-users] mod_managed users?

Michael Giagnocavo mgg at giagnocavo.net
Tue Jul 28 14:06:32 PDT 2009


Hello Lukasz,

        Thanks for testing mod_managed. I apologize for the problems you've encountered, and I'll try to sort them out for you.

A few things first:

        - Scripting support: This is made to allow "true" scripts, as invoked as an EXE - similar to the Lua and spidermonkey support. So, without a Main(), it won't compile as an EXE. If you aren't using it as a script, then an empty Main method will work fine.

        - Entry points must be public for Mono. I'll update the demo code to make sure that Main is public. This is a bug in Mono's lightweight code generation -- it won't skip the JIT access checks.

As to the main problem of your DLL not working, can you send me the full source code, or all the logging output from loading it? Try "managedreload my.dll" to reload the DLL and see how it is registering them. It should output something like "Registering API FullName with Aliases fullname, shortname".

Thanks,
Michael

-----Original Message-----
From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Lukasz Zwierko
Sent: Tuesday, July 28, 2009 1:26 PM
To: freeswitch-users at lists.freeswitch.org
Subject: Re: [Freeswitch-users] mod_managed users?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I've just tried new mod_managed under Win32 and I get a weird behavior.
I try the example below:

public class DemoScript : IApiPlugin
{
    public void Execute(ApiContext context)
    {
        context.Stream.Write(string.Format("DemoScripts executed with
args '{0}' and event type {1}.",
            context.Arguments, context.Event == null ? "<none>" :
context.Event.GetEventType()));
    }

    public void ExecuteBackground(ApiBackgroundContext context)
    {
        Log.WriteLine(LogLevel.Notice, "DemoScripts on a background
thread #({0}), with args '{1}'.",
            System.Threading.Thread.CurrentThread.ManagedThreadId,
            context.Arguments);
    }
}

It's just like the ApiDemo from Demo.cs

So When I copy DemoScript.csx to managed dir the console log is:

"
freeswitch at Zwierko-laptop> Loading
c:\Users\Zwierko\Projects\fs\svn\Debug\mod\managed\DemoScripts.csx from
domain DemoScripts.csx_3
2009-07-28 20:57:16.710000 [INFO] switch_cpp.cpp:1130 Compiling
c:\Users\Zwierko\Projects\fs\svn\Debug\mod\managed\DemoScripts.csx
2009-07-28 20:57:16.970000 [ERR] switch_cpp.cpp:1130 There were 1 errors
compiling
c:\Users\Zwierko\Projects\fs\svn\Debug\mod\managed\DemoScripts.csx.
2009-07-28 20:57:16.970000 [ERR] switch_cpp.cpp:1130 CS5001: Program
'c:\Users\Zwierko\AppData\Local\Temp\fc8jnlir.exe' does not contain a
static 'Main' method
suitable for an entry point
"

Adding

"
    public static void Main()
    {
    }
"

solves the issue. Is this how it's supposed to work?

Another strange thing is that when I compile this class to DLL (release)
it does not work at all...

freeswitch at Zwierko-laptop> Loading
c:\Users\Zwierko\Projects\fs\svn\Debug\mod\managed\FSScripts.dll from
domain FSScripts.dll_5


freeswitch at Zwierko-laptop>

freeswitch at Zwierko-laptop> managed DemoScript 111
API CALL [managed(DemoScript 111)] output:

2009-07-28 21:13:03.542000 [ERR] switch_cpp.cpp:1130 API plugin
DemoScript not found.
2009-07-28 21:13:03.542000 [ERR] mod_managed.cpp:393 Execute failed for
DemoScript 111 (unknown module or exception).

And another issue with scripts. I use script code as example:

"
public class ScriptDemo
{
    static void Main()
    {
        switch (FreeSWITCH.Script.ContextType)
        {
            case ScriptContextType.Api:
                {
                    var ctx = FreeSWITCH.Script.GetApiContext();
                    ctx.Stream.Write("Script executing as API with args:
" + ctx.Arguments);
                    break;
                }
            case ScriptContextType.ApiBackground:
                {
                    var ctx = FreeSWITCH.Script.GetApiBackgroundContext();
                    Log.WriteLine(LogLevel.Notice, "Executing as
APIBackground with args: " + ctx.Arguments);
                    break;
                }
            case ScriptContextType.App:
                {
                    var ctx = FreeSWITCH.Script.GetAppContext();
                    Log.WriteLine(LogLevel.Notice, "Executing as App
with args: " + ctx.Arguments);
                    break;
                }
        }

    }
}
"


console log is as follows:


freeswitch at Zwierko-laptop> Loading
c:\Users\Zwierko\Projects\fs\svn\Debug\mod\managed\Script.csx from
domain Script.csx_8
2009-07-28 21:19:36.289000 [INFO] switch_cpp.cpp:1130 Compiling
c:\Users\Zwierko\Projects\fs\svn\Debug\mod\managed\Script.csx
2009-07-28 21:19:36.438000 [INFO] switch_cpp.cpp:1130 File
c:\Users\Zwierko\Projects\fs\svn\Debug\mod\managed\Script.csx compiled
successfully.
2009-07-28 21:19:36.451000 [ERR] switch_cpp.cpp:1130 Entry point:
ScriptDemo.Main is not public. This may cause errors with Mono.
2009-07-28 21:19:36.458000 [NOTICE] switch_cpp.cpp:1130 Loaded App
Script.csx, aliases 'Script.csx', into domain Script.csx_8.
2009-07-28 21:19:36.459000 [NOTICE] switch_cpp.cpp:1130 Loaded Api
Script.csx, aliases 'Script.csx', into domain Script.csx_8.
2009-07-28 21:19:36.459000 [INFO] switch_cpp.cpp:1130 Finished loading
c:\Users\Zwierko\Projects\fs\svn\Debug\mod\managed\Script.csx into
domain Script.csx_8.
managed ScriptDemo 111
2009-07-28 21:19:53.452000 [ERR] switch_cpp.cpp:1130 API plugin
ScriptDemo not found.
API CALL [managed(ScriptDemo 111)] output:

2009-07-28 21:19:53.452000 [ERR] mod_managed.cpp:393 Execute failed for
ScriptDemo 111 (unknown module or exception).


Again, am I doing something wrong in here?

Thanks, for any feedback

Lukasz Zwierko





Michael Giagnocavo wrote:
> Ah, that’s embarrassing. I added them and tried building FreeSWITCH.Managed from svn and it worked fine now. (I’ll kick off a new complete build in a minute.)
>
> -Michael
>
> From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Diego Toro
> Sent: Sunday, July 26, 2009 8:47 AM
> To: freeswitch-users at lists.freeswitch.org
> Subject: Re: [Freeswitch-users] mod_managed users?
>
> Hi Michael,
>
> Thank you for your job with mod_managed, I get lastest version with mod_managed but the files PluginInterfaces.cs, PluginManager.cs and ScriptPluginManager.cs were not downloaded.
>
> Diego
>
>
> --- On Sun, 7/26/09, Michael Giagnocavo <mgg at giagnocavo.net> wrote:
>
> From: Michael Giagnocavo <mgg at giagnocavo.net>
> Subject: Re: [Freeswitch-users] mod_managed users?
> To: "freeswitch-users at lists.freeswitch.org" <freeswitch-users at lists.freeswitch.org>
> Date: Sunday, July 26, 2009, 2:18 AM
> Hello,
>
>                 I just checked in a new mod_managed. It breaks backwards compatibility, but adds scripting and reloading support.
>
>                 I tested it on CentOS 5.3 x64 with Mono 2.4.2.2. Just make & make install seemed to take care of everything.
>
>                 Let me know if you have better luck with this version.
>
> Thanks,
> Michael
>
> From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Muhammad Shahzad
> Sent: Saturday, July 18, 2009 6:58 AM
> To: freeswitch-users at lists.freeswitch.org
> Subject: Re: [Freeswitch-users] mod_managed users?
>
> Sorry for replying late.
>
> I have tried mod_managed again on same machine (Lenovo 3000 N200), same OS (Ubuntu-9.04) and Mono version 2.0.1 but with latest FS revision 14249.
>
> It compiles correctly this time but gives following error upon "make install",
>
> =====================================================================
> making install mod_managed
> make[5]: *** No rule to make target `/usr/local/freeswitch/mod/mod_managed.so', needed by `local_install'.  Stop.
> make[4]: *** [install] Error 1
> make[3]: *** [mod_managed-install] Error 1
> make[2]: *** [install-recursive] Error 1
>
> =====================================================================
>
> Here is compilation log when executing "make", if it could of any help.
>
> =====================================================================
> making all mod_managed
> Compiling freeswitch_managed.cpp...
> g++ -I/usr/src/svn-src/freeswitch/src/include -I/usr/src/svn-src/freeswitch/libs/libteletone/src -fPIC -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 -g -O2 -D_GNU_SOURCE -D_REENTRANT -pthread -I/usr/include/mono-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -DHAVE_CONFIG_H -c -o freeswitch_managed.o freeswitch_managed.cpp
> Compiling freeswitch_wrap.cpp...
> g++ -I/usr/src/svn-src/freeswitch/src/include -I/usr/src/svn-src/freeswitch/libs/libteletone/src -fPIC -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 -g -O2 -D_GNU_SOURCE -D_REENTRANT -pthread -I/usr/include/mono-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -DHAVE_CONFIG_H -c -o freeswitch_wrap.o freeswitch_wrap.cpp
> Demo.cs(58,14): warning CS0169: The private method `FreeSWITCH.Demo.AppDemo.hangupHook()' is never used
> Compilation succeeded - 1 warning(s)
> Compiling mod_managed.cpp...
> /usr/src/svn-src/freeswitch/libtool --mode=compile --tag=CXX g++ -I/usr/src/svn-src/freeswitch/src/include -I/usr/src/svn-src/freeswitch/libs/libteletone/src -fPIC -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 -g -O2 -D_GNU_SOURCE -D_REENTRANT -pthread -I/usr/include/mono-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -DHAVE_CONFIG_H -c -o mod_managed.lo mod_managed.cpp
> libtool: compile:  g++ -I/usr/src/svn-src/freeswitch/src/include -I/usr/src/svn-src/freeswitch/libs/libteletone/src -fPIC -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 -g -O2 -D_GNU_SOURCE -D_REENTRANT -pthread -I/usr/include/mono-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -DHAVE_CONFIG_H -c mod_managed.cpp  -fPIC -DPIC -o .libs/mod_managed.o
> mod_managed.cpp: In function ‘void InitManagedSession(ManagedSession*, char* (*)(void*, switch_input_type_t), void (*)())’:
> mod_managed.cpp:97: warning: deprecated conversion from string constant to ‘char*’
> libtool: compile:  g++ -I/usr/src/svn-src/freeswitch/src/include -I/usr/src/svn-src/freeswitch/libs/libteletone/src -fPIC -fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 -g -O2 -D_GNU_SOURCE -D_REENTRANT -pthread -I/usr/include/mono-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -DHAVE_CONFIG_H -c mod_managed.cpp -o mod_managed.o >/dev/null 2>&1
> Creating mod_managed.la...
> cat: .libs/mod_managed.log: No such file or directory
>
> =====================================================================
>
> Thank you.
> On Fri, Jul 17, 2009 at 10:59 AM, Muhammad Shahzad <shaheryarkh at googlemail.com<http://us.mc335.mail.yahoo.com/mc/compose?to=shaheryarkh@googlemail.com>> wrote:
> I tried to install mod_managed on ubuntu-9.04, mono framework version 2.0. It gave me a lots of errors in Loader.cs, which seems to be SWIG related. Since i am not a expert in SWIG so i disabled this module. This happend long ago, i think FS svn revision 136xx.
>
> Let me try to compile it from latest FS revision and see if it works. I will let you know the results.
>
> Thank you.
>
> On Fri, Jul 17, 2009 at 3:54 AM, Diego Toro <dftoro at yahoo.com<http://us.mc335.mail.yahoo.com/mc/compose?to=dftoro@yahoo.com>> wrote:
> Hey, I am here  :)
>
> I am working with mod_managed on Windows 2003 and Windows Vista with sucessfull.  I noted on user list the issue with LoadFile on Loader.cs when a assembly had reference to others assemblies, I change LoadFile by LoadFrom and the load is made fine.
>
> I use c# application and sqlserver 2005, using FS and mod_managed.
>
> Diego
>
> --- On Thu, 7/16/09, Michael Giagnocavo <mgg at giagnocavo.net<http://us.mc335.mail.yahoo.com/mc/compose?to=mgg@giagnocavo.net>> wrote:
>
> From: Michael Giagnocavo <mgg at giagnocavo.net<http://us.mc335.mail.yahoo.com/mc/compose?to=mgg@giagnocavo.net>>
> Subject: [Freeswitch-users] mod_managed users?
> To: "freeswitch-users at lists.freeswitch.org<http://us.mc335.mail.yahoo.com/mc/compose?to=freeswitch-users@lists.freeswitch.org>" <freeswitch-users at lists.freeswitch.org<http://us.mc335.mail.yahoo.com/mc/compose?to=freeswitch-users@lists.freeswitch.org>>
> Date: Thursday, July 16, 2009, 4:43 PM
>
> Hey, if there are any mod_managed users on this list, I’d love it if you were able to let me know. I’d like to get feedback, positive or negative, on what worked, what didn’t, and how mod_managed can improve for you. Feel free to write on list or directly to me: mgg at giagnocavo.net<http://giagnocavo.net/>
>
> Thanks!
> -Michael
> -----Inline Attachment Follows-----
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org<http://us.mc335.mail.yahoo.com/mc/compose?to=FreeSWITCH-users@lists.freeswitch.org>
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org<http://www.freeswitch.org/>
>
>
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org<http://us.mc335.mail.yahoo.com/mc/compose?to=FreeSWITCH-users@lists.freeswitch.org>
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org<http://www.freeswitch.org/>
>
>
> --
> Muhammad Shahzad
> -----------------------------------
> CISCO Rich Media Communication Specialist (CRMCS)
> CISCO Certified Network Associate (CCNA)
> Cell: +92 334 422 40 88
> MSN: shari_786pk at hotmail.com<http://us.mc335.mail.yahoo.com/mc/compose?to=shari_786pk@hotmail.com>
> Email: shaheryarkh at googlemail.com<http://us.mc335.mail.yahoo.com/mc/compose?to=shaheryarkh@googlemail.com>
>
>
>
> --
> Muhammad Shahzad
> -----------------------------------
> CISCO Rich Media Communication Specialist (CRMCS)
> CISCO Certified Network Associate (CCNA)
> Cell: +92 334 422 40 88
> MSN: shari_786pk at hotmail.com<http://us.mc335.mail.yahoo.com/mc/compose?to=shari_786pk@hotmail.com>
> Email: shaheryarkh at googlemail.com<http://us.mc335.mail.yahoo.com/mc/compose?to=shaheryarkh@googlemail.com>
>
> -----Inline Attachment Follows-----
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org<http://us.mc335.mail.yahoo.com/mc/compose?to=FreeSWITCH-users@lists.freeswitch.org>
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org<http://www.freeswitch.org/>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEcBAEBAgAGBQJKb1CvAAoJED7LBosr0F2u6E4H/i0SVOJDrh4+3ex6nEDnVJQl
mLjTPpyoAyP3cEp37YmQbrk2DAqfmQgysygaiKP6yxdFsyDsPmphMV1biWGi8DgM
pwTiGQACFdWWiWiYk/J09ZbRJR24S8zHxuETQK93/7fy53tgqW6o35hLxb3arOaH
VOAUDHQkMX7Q/PFaorWk/bhYDbq6+XxwkBCQHeMk3zErZT1rl+haxVtBXN1N0h8+
k5t3C5bJpPNjpTmm4m0BEOdA7WfU2iFIJeOH9ZoHih01n68COnb52pl349Ah2fV8
cVVouTbOtjGsRpyq9OYh7XhIFzH/QUZQykL/BMlR3Df3g8KRJ8Q8p/zj5bNRDlA=
=LgK4
-----END PGP SIGNATURE-----

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org


More information about the FreeSWITCH-users mailing list