[IronPython] Question on loading assembly from byte array

Samuel Tjokrosoesilo samuelt at gmail.com
Thu Apr 2 21:40:18 CEST 2009


Wow, thanks a lot, Dino. I went ahead and imported the Assembly from
System.Reflection and it resolved it.

Samuel
2009/4/2 Dino Viehland <dinov at microsoft.com>

>  You can do:
>
>
>
> import clr
>
> from System.IO import File
>
> clr.AddReference(Assembly.Load(File.ReadAllBytes(assemblyName)))
>
>
>
> *From:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *On Behalf Of *Samuel Tjokrosoesilo
> *Sent:* Thursday, April 02, 2009 10:43 AM
> *To:* Discussion of IronPython
> *Subject:* [IronPython] Question on loading assembly from byte array
>
>
>
> I would like to be able to load assembly from byte array inside of
> IronPython.
>
> Is there any way to do it directly in IronPython? I'm unable to run
> something like clr.AddReference(byte []).
>
>
>
>
>
> Below is what I do in .NET DLR in order to make this work:
>
> byte
>
> [] rawAssemblyFile = File.ReadAllBytes(assemblyName);
>
> Runtime.LoadAssembly(Assembly.Load(rawAssemblyFile));
>
>
>
> Another alternative that I use would be the following:
>
> C#
>
> byte[] rawAssemblyFile = File.ReadAllBytes(assemblyName);
>
> Assembly
>
> rawAssembly = Assembly.Load(rawAssemblyFile);
>
> Scope.SetVariable(
>
> "rawAssembly", rawAssembly);
>
> Python
>
> import clr
>
> clr.AddReference(rawAssembly)
>
>
>
> I'm just wondering if there's a cleaner way to do this whole thing inside
> of IronPython.
>
> Thanks.
>
> Samuel
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090402/af27c5ec/attachment.html>


More information about the Ironpython-users mailing list