I've got this working on my private (for the moment) branch. I could do this merge by this weekend if folks will find it useful.
-Barton

On 1/6/2011 6:59 AM, Oleksii Bidiuk wrote:
Hi Alla,

thanks for your prompt repsonse. In Python terms String('A') means constructor with a string parameter AFAIK. When I use the python.exe build against CLR 2.0 (from pythonnet-2.0-alpha2-clr2.0_115_py26.zip) it works, but then it talks against .NET 2.0 while I want to talk to the same 4.0 version as my .NET application.

With the example below using the .NET 2.0 version I get

>>> s = String.__overloads__[Char, Int32]('A', 10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'String' has no attribute '__overloads__'

Basically it seems that the version of python for .net compiled against .NET 4.0 runtime does not work out of box for me. I wonder if somebody had more luck with this.

2011/1/6 Alla Gofman <alla.gof...@sandisk.com <mailto:alla.gof...@sandisk.com>>

    Hi Oleksii,

    I have no experience with importing .net modules into Python.

    I work on embedding Python into C#.

    There is no such constructor String('A')for String class as you
    use, which gets char.

    You can see which constructors exists in:
    http://msdn.microsoft.com/en-us/library/system.string.string.aspx

    Example:

    I read in http://pythonnet.sourceforge.net/readme.html

    In most cases, Python for .NET can determine the correct
    constructor to call automatically based on the arguments. In some
    cases, it may be necessary to call a particular overloaded
    constructor, which is supported by a special "__overloads__"
    attribute on a class:

        from System import String, Char, Int32

        s = String.__overloads__[Char, Int32]('A', 10)

    I hope you succeed,


    Alla

    *From:*pythondotnet-bounces+alla.gofman=sandisk.com
    <http://sandisk.com>@python.org <http://python.org>
    [mailto:pythondotnet-bounces+alla.gofman
    <mailto:pythondotnet-bounces%2Balla.gofman>=sandisk.com
    <http://sandisk.com>@python.org <http://python.org>] *On Behalf Of
    *Oleksii Bidiuk
    *Sent:* Thursday, January 06, 2011 4:27 PM
    *To:* pythondotnet@python.org <mailto:pythondotnet@python.org>
    *Subject:* [Python.NET] PythonNET 2.0 Alpha2 and .NET 4.0

    Hi,

    I am trying to use Python for .NET under VS2010 and .NET 4.0. I've
    downloaded the pythonnet-2.0-alpha2.zip and changed the project
    settings to use .NET 4.0 under VS2010 and recompiled everything.
    The resulting python.exe can be run, and statements like "import
    clr" and "from System import String" work (as the Python standard
    library calls as well) until I try to instantiate a class as e.g.

    s = String('A')

    At this moment the Python for .NET seem to crash in nativecall.cs
    at NativeCall.Call_3() at (the only) line

    return Impl.Call_3(fp, a1, a2, a3);

    with dreaded "Exception of type 'System.ExecutionEngineException'
    was thrown.". Trying to instantiate Int32() object results in
    "Attempted to read or write protected memory. This is often an
    indication that other memory is corrupt."

    Suggestions are more than welcome! Thanks in advance!
-- oleksii


    ------------------------------------------------------------------------
    PLEASE NOTE: The information contained in this electronic mail
    message is intended only for the use of the designated
    recipient(s) named above. If the reader of this message is not the
    intended recipient, you are hereby notified that you have received
    this message in error and that any review, dissemination,
    distribution, or copying of this message is strictly prohibited.
    If you have received this communication in error, please notify
    the sender by telephone or e-mail (as shown above) immediately and
    destroy any and all copies of this message in your possession
    (whether hard copies or electronically stored copies).




--
oleksii



--
oleksii


_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Reply via email to