I'm having a go at automating Microsoft Virtual Server 2005 R2 using the COM
API's via IronRuby.
Virtual Server requires the COM security level to be set to 'Impersonation'
or higher (as mentioned here
http://msdn.microsoft.com/en-us/library/aa367595(VS.85).aspx )

The sample code is missing from that particular MSDN page, but essentially
what it does is call CoInitializeSecurity as follows

CoInitializeSecurity(IntPtr.Zero,
            -1,
            IntPtr.Zero,
            IntPtr.Zero,
            (uint)RpcAuthnLevel.PktPrivacy,
            (uint)RpcImpLevel.Impersonate,
            IntPtr.Zero,
            (uint)EoAuthnCap.DynamicCloaking,
            IntPtr.Zero);

I've created a small C# wrapper dll which does that, but when I try to call
it from within IronRuby, the following exception occurs:

:0: Security must be initialized before any interfaces are marshalled or
unmarshalled. It cannot be changed once initialized. (Exception from
HRESULT: 0x80010119) (System::Runtime::InteropServices::COMException)

This implies that IronRuby is doing some COM or marshalling stuff
internally, and it's too late for me to call CoInit.

Thus far, I'm stumped - Is there anything I can do to work around this?

Thanks a lot, Orion.

PS: I'm using IronRuby 0.9. I've been really impressed by the performance
improvements since earlier versions, congratulations on all the good work so
far. Just need to improve the startup time and it'll be awesome!
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to