<div dir="ltr"><div>It wouldn&#39;t be sufficient to recompile with /clr.&nbsp; When you do that, your classes don&#39;t automatically become managed classes.&nbsp; You would still need to either modify your classes or to create wrappers using C++/CLI (<a href="http://en.wikipedia.org/wiki/C%2B%2B/CLI">http://en.wikipedia.org/wiki/C%2B%2B/CLI</a>).&nbsp; In order for a C++ class to be visible to IronPython, it would need to be declared as a &quot;ref class&quot; -- you can see more about that at the referenced Wikipedia article.</div>

<div><br>&nbsp;</div>
<div class="gmail_quote">On Thu, Jul 31, 2008 at 9:22 AM, Anders Elfgren <span dir="ltr">&lt;<a href="mailto:anders.elfgren@avalanchestudios.se">anders.elfgren@avalanchestudios.se</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div><font face="Arial" size="2"><span>Hi, </span></font></div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span>First let me say that I&#39;m new to Iron Python, but at least I&#39;ve read this in the FAQ.. :)</span></font></div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span>Q: How do I build and call into <b style="COLOR: black; BACKGROUND-COLOR: rgb(160,255,255)">PYD</b> libraries?</span></font></div>
<div><font face="Arial" size="2"><span>A: <b style="COLOR: black; BACKGROUND-COLOR: rgb(255,255,102)">IronPython</b> does not support using PYDs built for CPython since they leverage implementation details of CPython.&nbsp; You can get a similar effect for new &quot;<b style="COLOR: black; BACKGROUND-COLOR: rgb(160,255,255)">PYD</b>&quot;s you would like to implement by writing them in C# or VB and building a DLL for .NET.</span></font></div>

<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span>That said, I&#39;ve got some questions to see if what I&#39;m doing is possible anyway.</span></font></div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span>We&#39;ve got a c library of which most of the code has also been written in Python. We want to create an editor using .net forms which we can use to edit some files, and to do that we need some data structures that exist in this library. </span></font></div>

<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span>My current idea is to interface against the python library using IronPython, and then accessing the datastructures through that in C# (although if absolutely necessary, we could write the editor in IronPython too). The thing that is standing against me now is that one function that exists a small C dll. Since IronPython can&#39;t access this (unless this has changed since the FAQ was written?), I was thinking that maybe I can compile the dll using the /clr flag and thus get a .net assembly. Would I then be able to use the function?</span></font></div>

<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span>The Python code just tries to import it:</span></font></div>
<div><font face="Arial" size="2"><span>import&nbsp;AvHash</span></font></div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span>And then use it..</span></font></div>
<div><font face="Arial" size="2"><span>def AdfHash(str):<br>&nbsp;&nbsp;&nbsp; return AvHash.HashString(str)</span></font></div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span>At the import statement, this error is raised:</span></font></div>
<div><font face="Arial" size="2"><span>Traceback (most recent call last):<br>&nbsp; File X:\ctg\libs\ADF\main\common\modeditor.ipy, line 20, in Initialize<br>&nbsp; File , line 0, in __import__##4<br>&nbsp; File X:\ctg\libs\ADF\main\common\AdfLib.py, line 1, in Initialize<br>
&nbsp; File , line 0, in __import__##4<br>ImportError: No module named AvHash</span></font></div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span>Or is there some other solution? I&#39;ve just started researching how to interface between C/C#/Python/IronPython so there may well be things I haven&#39;t heard of...</span></font></div>

<div><font face="Arial" size="2"><span>I hope I&#39;ve made my problem clear, thanks for any responses. :)</span></font></div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div>
<div><font face="Arial" size="2"><span>/Anders</span></font></div>
<div><font face="Arial" size="2"><span></span></font>&nbsp;</div></div><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br><br></blockquote></div><br></div>