是npython.exe运行使用python.n导入.net dll的python脚本的唯一选项

2024-05-13 03:22:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码库主要在.net框架中。我试图通过python.net. 我能让它成功运行

  1. 正在下载python.net源代码,然后构建npython.exe/python.运行时.dll从源头
  2. 像这样运行python脚本npython.exe MyPythonScript.py

一切如期进行。在

但是,如果不使用我的npython版本,而是使用pip在我的anaconda python中直接安装pythonnet包,然后尝试运行C:\Anaconda3\python MyPythonScript.py这样的脚本,我会得到如下错误

The deserializer cannot load the type to deserialize because type 'System.Collections.Generic.List`1[[RefData.LookUpDataItem, RefData, Version=1.0.6841.27933, Culture=neutral, PublicKeyToken=null]]' could not be found in assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Check that the type being serialized has the same contract as the type being deserialized and the same assembly is used.
   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, String name, String ns)
   at System.Runtime.Serialization.NetDataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at Microsoft.ApplicationServer.Caching.Utility.Deserialize(Byte[][] buffers, Boolean checkTypeToLoad, Object context, IEnumerable`1 knownTypes)
   at Microsoft.ApplicationServer.Caching.RoutingClient.SendMsgAndWait(RequestBody reqMsg, IRequestTracker& tracker)
   at Microsoft.ApplicationServer.Caching.DataCache.SendReceive(RequestBody reqMsg, IMonitoringListener listener)
   at Microsoft.ApplicationServer.Caching.DataCache.InternalGet(String key, DataCacheItemVersion& version, String region, IMonitoringListener listener)
   at Microsoft.ApplicationServer.Caching.DataCache.<>c__DisplayClass49.<Get>b__48()

该程序从Microsoft AppFabric缓存服务器检索一些数据。缓存DLL位于同一位置。我的库dll或使用它们的python脚本没有任何更改。只是不同的召唤。在

在anancodapython3.6安装和独立的python2.7安装中也可以观察到相同的行为。这是完全不可能的吗?还是有什么特定的缓存和序列化导致了这些问题?如果有任何帮助,我们将不胜感激。在


Tags: the脚本stringnettypeserializationsystemat