1

Recently I've been working on a project which needs to use a .NET 3.5 Dll library, and the team is using Python3.x environment.

So I went to the Python for .NET's github repo and downloaded the source code and tried compiling myself using Visual Studio 2013.

In the source, there is a MVSC solution file named pythonnet, and I just opened the project and tried compiling Python.Runtime.

By default, the Conditional compilation symbols is PYTHON27, UCS4. So I changed it to PYTHON35, UCS2 to match my requirement. And I was able to compile it successfully. python35

But since it needs to work with .NET Framework 3.5, then I changed Target Framework from .NET Framework 4.0 to .NET Framework 3.5. But this time I got a lot of errors when compiling and the compilation failed.DotNET3.5

Could anyone please help me with the compilation so that I can compile the Python for .NET which works for both .NET 3.5 and Python3.x?

0

1 Answer 1

2

Latest pythonnet is using HashSet from CLR 4.0 and also dynamic from DLR which cannot be easily backported to older .NET versions.

What you can do is redirect your other DLLs from .NET 3.5 to CLR 4.0 using app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
    </startup>
</configuration>
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks so much for your answer! But the problem is my other DLLs are provided by third-party, which means I don't have the source code for it. Is there a way I can convert?
You can just reference your 3rd party .NET 2.0 dlls from Visual Studio project that is configured for .NET 4.0. I do this all the time!
Thanks so much for your quick response. But I'm directly using the DLL from Python by Pythonnet, no Visual Studio project involved.. I don't quite understand what you mean..
If you are directly using 3rd party .NET 3.5 dll from python using pythonnet, then app.config should be placed next to python executable - python.exe.config - this is different exe if you use ipython, ptipython, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.