适用于.NET3.5和Python3.x的.NET编译Python [英] Python for .NET compilation for .NET3.5 and Python3.x

查看:136
本文介绍了适用于.NET3.5和Python3.x的.NET编译Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我一直在一个需要使用 .NET 3.5 Dll库的项目中,而该团队正在使用Python3.x环境。



所以我去了



但是由于它需要使用 .NET Framework 3.5 ,然后将 Target Framework .NET Framework 4.0 更改为 .NET Framework 3.5 。但是这次,编译时出现了很多错误,编译失败。



有人可以帮助我进行编译吗?这样我就可以编译适用于 .NET 3.5 Python3.x Python for .NET 了?

解决方案

最新的pythonnet使用的是CLR 4.0中的 HashSet 以及 dynamic 不能轻易地反向移植到较旧的.NET版本。



您可以做的是使用以下方法将其他DLL从.NET 3.5重定向到CLR 4.0 app.config:

 <?xml version = 1.0 encoding = utf-8吗? 
< configuration>
< startup useLegacyV2RuntimeActivationPolicy = true>
< supportedRuntime版本= v4.0 />
< / startup>
< / configuration>


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.

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.

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?

解决方案

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>

这篇关于适用于.NET3.5和Python3.x的.NET编译Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆