[IronPython] Accessing C++ managed class libraries

Curt Hagenlocher curt at hagenlocher.org
Sun Jul 6 20:36:01 CEST 2008


Using basically this same code, it works for me.  I'm using VS2008 Pro and
IronPython 2.0b3.  When creating the project in Visual Studio, I just picked
"Class Library" under Visual C++/CLR in the "New Project" dialog.

Can you email me a zipped copy of your DLL?

On Sun, Jul 6, 2008 at 10:40 AM, Todd Gruben <tgruben at gmail.com> wrote:

> here is my quick and dirty class..
>
>
>
> using namespace System;
>
> namespace dtnnet {
>
>     public ref class Feed
>     {
>         // TODO: Add your methods for this class here.
>     public:
>
>         String^ test(void)
>         {
>             return "Hello World";
>         }
>     };
> }
>
>
> The Reflector says that this is the full path..
> C:\Documents and Settings\tgruben\My Documents\Visual Studio
> 2008\Projects\dtnnet\Debug\dtnnet.dll
>
>
> yet here is the output of my AddReference Attempt..
>
>
> C:\Documents and Settings\tgruben\My Documents\Visual Studio
> 2008\Projects\dtnnet\Debug>ipy
> IronPython 2.0 Beta (2.0.0.3000) on .NET 2.0.50727.1433
> Copyright (c) Microsoft Corporation. All rights reserved.
> >>> import clr
> >>> clr.AddReferenceToFileAndPath(r"C:\Documents and Settings\tgruben\My
> Documents\Visual Studio 2008\Projects\dtnnet\Debug\dtnnet.dll")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> IOError: file does not exist: C:\Documents and Settings\tgruben\My
> Documents\Visual Studio 2008\Projects\dtnnet\Debug\dtnnet.dll
> >>>
>
> yet i can do this ..
> f = open(r""C:\Documents and Settings\tgruben\My Documents\Visual Studio
> 2008\Projects\dtnnet\Debug\dtnnet.dll","r").read()
> and print len(f) and get 36k which is the size of the file.
>
> I'm sure its a configuration setting... if i point the addreferrence
> function to my c# library it just works.  The c# does exactly the same
> thing, return a string.
>
>
> Also if i just try and do AddReference("dtnnet.dll") from that directory,
> it just says failed to load assembly
>
>
> I'm clueless..
>
> -Todd
>
>
> _______________________________________________
> 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/20080706/85a636ff/attachment.html>


More information about the Ironpython-users mailing list