[IronPython] calling a named def

Christian Schmidt christian2.schmidt at gmx.de
Sun Nov 14 21:23:45 CET 2010


Hi Lee,

I've come across the same problem with C++/CLI and System::Func. IIRC 
the compiler error is a known bug and it will not be fixed - at least 
for VS 2008.
I worked around the missing/buggy System::Func<>^ by using Delegate^:

Delegate^ obj;
if (scope->TryGetVariable<Delegate^>("MyFunc", obj))
{
   obj->Invoke();
}

Regards,
Christian

L. Lee Saunders wrote:
> Everyone,
>
> I have a c++/cli application (.net 3.5) that I an adding IronPython to.
>
> In C# I can call the def (lets call it MyFunc) with this code:
>
> Func<object> obj;
> if(Scope.TryGetVariable("MyFunc", outobj)) { obj(); }
>
> I tried this code:
>
> System::Func<Object>^ obj;
> if (scope->TryGetVariable<System::Func<Object>^>("MyFunc", obj))
> {
> obj->Invoke();
> }
>
> But it seems that .net 3.5 c++/cli does not have Func<>.
>
> Is there a way to do this in c++/cli? Can this be done with a standard
> delegate? (I've searched the web - I found that maybe I could get Func<>
> from System.Core.dll, but #using<System.Core.dll> mgenerates a compiler
> error. Seems that System.Core.dll does not exist on my machine.)
>
> L. Lee Saunders




More information about the Ironpython-users mailing list