- Notifications
You must be signed in to change notification settings - Fork748
problems in loading c# dll in python#2569
-
Hi, https://github.com/pythonnet/pythonnet/wiki/How-to-call-a-dynamic-library and everything goes fine. I created a c# dll project in Visual Studio Code, I copied the "calculate" code in the Class1.cs that was automatically generated by VS Code, I generated the dll, I moved it in the folder of my python example and I was able to run the example as it is in the tutorial. Everything was fine. using System; namespace CalcTestNS
} I followed the procedure as before but now the python example fails at the from CalcTestNS import calculate Do you have any suggestion? System.TypeLoadException: Non è stato possibile caricare il tipo 'System.Runtime.CompilerServices.NullableContextAttribute' dall'assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. in System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) The above exception was the direct cause of the following exception: Traceback (most recent call last): |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 2 comments 4 replies
-
It seems like there is some issue with your csproj try setting it to:
hope that helps |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi, |
BetaWas this translation helpful?Give feedback.
All reactions
-
Just fyi: 8.0 also worked for me. Might be that they also support the lts versions. I didn't find the corresponding docs either |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi, I tried also 8.0 and it works. System.TypeLoadException: Non è stato possibile caricare il tipo 'System.Globalization.CultureInfo' dall'assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or System.TypeLoadException: Non è stato possibile caricare il tipo 'System.ValueTuple`2' dall'assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Commenting some parts of the code everything works. I tried to search online and tried some suggestions like adding this in my .csproj
but it doesn't work .. I'm a newbie of c#. Do you have any idea? |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
There might be a problem with your dotnet installation or your dll. Did you use |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi, One of the line that creates problem is when I parse a csv file and I do t0 = DateTime.ParseExact(lsInputDataWithoutHeader[0].TimeStamp, "dd/MM/yyyy; HH:mm:ss:FF", I'm asking also the support of a colleague who daily uses c# with Visual Studio. |
BetaWas this translation helpful?Give feedback.