[Python.NET] Pythonnet causes Exception has occurred: "TypeLoadException" when running .net dll on linux
Hossam Alzomor <[email protected]> Tue, 27 Sep 2022 09:19:49 +0000
| Newsgroups | gmane.comp.python.dotnet |
|---|---|
| Message-ID | <[email protected]> |
--===============7337929025948025280==
Content-Type: multipart/alternative;
boundary="_000_364cacdf21084613be914d2d7141ed6amechalesscom_"
--_000_364cacdf21084613be914d2d7141ed6amechalesscom_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello,
I have a dotnet dll build using dotnet6.0 on Ubuntu 20.04.
I could use the dll using C# application.
but when I try to test it using python script with pythonnet on Ubuntu 20.0=
4 , I get the following error
"
Exception has occurred: TypeLoadException
Could not load type of field 'ElmosLCC.ElmosLidarController:_updateWatchdog=
' (37) due to: Could not resolve type with token 0100004a from typeref (exp=
ected class 'System.Timers.Timer' in assembly 'System.ComponentModel.TypeCo=
nverter, Version=3D6.0.0.0, Culture=3Dneutral, PublicKeyToken=3Db03f5f7f11d=
50a3a') assembly:System.ComponentModel.TypeConverter, Version=3D6.0.0.0, Cu=
lture=3Dneutral, PublicKeyToken=3Db03f5f7f11d50a3a type:System.Timers.Timer=
member:(null) at (wrapper managed-to-native)
System.RuntimeType.GetFields_native(System.RuntimeType,intptr,System.Reflec=
tion.BindingFlags,System.RuntimeType/MemberListType)
at System.RuntimeType.GetFields_internal (System.String name, System.Reflec=
tion.BindingFlags bindingAttr, System.RuntimeType+MemberListType listType, =
System.RuntimeType reflectedType) [0x0001b] in <de882a77e7c14f8ba5d298093dd=
e82b2>:0
at System.RuntimeType.GetField (System.String name, System.Reflection.Bindi=
ngFlags bindingAttr) [0x00015] in <de882a77e7c14f8ba5d298093dde82b2>:0
at System.Type.GetField (System.String name) [0x00000] in <de882a77e7c14f8b=
a5d298093dde82b2>:0
at Python.Runtime.ClassManager.CreateClass (System.Type type) [0x00079] in =
<3972e4befd8f45a1b7c0e96a8f1f659a>:0
at Python.Runtime.ClassManager.GetClass (System.Type type) [0x00015] in <39=
72e4befd8f45a1b7c0e96a8f1f659a>:0
at Python.Runtime.ModuleObject.GetAttribute (System.String name, System.Boo=
lean guess) [0x0008e] in <3972e4befd8f45a1b7c0e96a8f1f659a>:0
at Python.Runtime.ModuleObject.tp_getattro (System.IntPtr ob, System.IntPtr=
key) [0x00073] in <3972e4befd8f45a1b7c0e96a8f1f659a>:0
"
I tested the dll on windows machine with pythonnet and it's working fine.
Best Regards
Hossam Alzomor
[IZB Wolfsburg 2022 | Hall 2 | Booth 2405 | 11 - 13 Oct, 2022 | Wolfsburg]
--_000_364cacdf21084613be914d2d7141ed6amechalesscom_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"var\(--ff-mono\)";
panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:inherit;
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";
mso-fareast-language:DE;}
span.hljs-keyword
{mso-style-name:hljs-keyword;}
span.hljs-string
{mso-style-name:hljs-string;}
span.hljs-number
{mso-style-name:hljs-number;}
span.hljs-function
{mso-style-name:hljs-function;}
span.hljs-title
{mso-style-name:hljs-title;}
span.hljs-params
{mso-style-name:hljs-params;}
span.hljs-literal
{mso-style-name:hljs-literal;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:8.5in 11.0in;
margin:70.85pt 70.85pt 56.7pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"DE" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Hello,<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">I have a dotnet dll build using=
dotnet6.0 on Ubuntu 20.04.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">I could use the dll using C# ap=
plication.<br>
but when I try to test it using python script with pythonnet on Ubuntu 20.0=
4 , I get the following error<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">“<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"vertical-align:baseline"><span lang=3D"EN-U=
S" style=3D"font-size:10.0pt;font-family:"inherit",serif;border:n=
one windowtext 1.0pt;padding:0in;mso-fareast-language:DE">Exception has occ=
urred: TypeLoadException<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"vertical-align:baseline"><span lang=3D"EN-U=
S" style=3D"font-size:10.0pt;font-family:"inherit",serif;border:n=
one windowtext 1.0pt;padding:0in;mso-fareast-language:DE">Could not load ty=
pe of field 'ElmosLCC.ElmosLidarController:_updateWatchdog'
(37) due to: Could not resolve type with token 0100004a from typeref (expe=
cted class 'System.Timers.Timer' in assembly 'System.ComponentModel.TypeCon=
verter, Version=3D6.0.0.0, Culture=3Dneutral, PublicKeyToken=3Db03f5f7f11d5=
0a3a') assembly:System.ComponentModel.TypeConverter,
Version=3D6.0.0.0, Culture=3Dneutral, PublicKeyToken=3Db03f5f7f11d50a3a ty=
pe:System.Timers.Timer member:(null) at (wrapper managed-to-native)<o=
:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"vertical-align:baseline"><span lang=3D"EN-U=
S" style=3D"font-size:10.0pt;font-family:"inherit",serif;border:n=
one windowtext 1.0pt;padding:0in;mso-fareast-language:DE">System.RuntimeTyp=
e.GetFields_native(System.RuntimeType,intptr,System.Reflection.BindingFlags=
,System.RuntimeType/MemberListType)<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"vertical-align:baseline"><span lang=3D"EN-U=
S" style=3D"font-size:10.0pt;font-family:"inherit",serif;border:n=
one windowtext 1.0pt;padding:0in;mso-fareast-language:DE">at System.Runtime=
Type.GetFields_internal (System.String name, System.Reflection.BindingFlags
bindingAttr, System.RuntimeType+MemberListType listType, System.Runtim=
eType reflectedType) [0x0001b] in <de882a77e7c14f8ba5d298093dde82b2>:=
0
<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"vertical-align:baseline"><span lang=3D"EN-U=
S" style=3D"font-size:10.0pt;font-family:"inherit",serif;border:n=
one windowtext 1.0pt;padding:0in;mso-fareast-language:DE">at System.Runtime=
Type.GetField (System.String name, System.Reflection.BindingFlags
bindingAttr) [0x00015] in <de882a77e7c14f8ba5d298093dde82b2>:0<o:p><=
/o:p></span></p>
<p class=3D"MsoNormal" style=3D"vertical-align:baseline"><span lang=3D"EN-U=
S" style=3D"font-size:10.0pt;font-family:"inherit",serif;border:n=
one windowtext 1.0pt;padding:0in;mso-fareast-language:DE">at System.Type.Ge=
tField (System.String name) [0x00000] in <de882a77e7c14f8ba5d298093dde82=
b2>:0<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"vertical-align:baseline"><span lang=3D"EN-U=
S" style=3D"font-size:10.0pt;font-family:"inherit",serif;border:n=
one windowtext 1.0pt;padding:0in;mso-fareast-language:DE">at Python.Runtime=
.ClassManager.CreateClass (System.Type type) [0x00079]
in <3972e4befd8f45a1b7c0e96a8f1f659a>:0<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"vertical-align:baseline"><span lang=3D"EN-U=
S" style=3D"font-size:10.0pt;font-family:"inherit",serif;border:n=
one windowtext 1.0pt;padding:0in;mso-fareast-language:DE">at Python.Runtime=
.ClassManager.GetClass (System.Type type) [0x00015]
in <3972e4befd8f45a1b7c0e96a8f1f659a>:0<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"vertical-align:baseline"><span lang=3D"EN-U=
S" style=3D"font-size:10.0pt;font-family:"inherit",serif;border:n=
one windowtext 1.0pt;padding:0in;mso-fareast-language:DE">at Python.Runtime=
.ModuleObject.GetAttribute (System.String name, System.Boolean
guess) [0x0008e] in <3972e4befd8f45a1b7c0e96a8f1f659a>:0<o:p></o:p><=
/span></p>
<p class=3D"MsoNormal" style=3D"vertical-align:baseline"><span lang=3D"EN-U=
S" style=3D"font-size:10.0pt;font-family:"inherit",serif;border:n=
one windowtext 1.0pt;padding:0in;mso-fareast-language:DE">at Python.Runtime=
.ModuleObject.tp_getattro (System.IntPtr ob, System.IntPtr
key) [0x00073] in <3972e4befd8f45a1b7c0e96a8f1f659a>:0 </span><span =
lang=3D"EN-US" style=3D"font-size:10.0pt;font-family:"var(--ff-mono)&q=
uot;,serif;mso-fareast-language:DE"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">“<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">I tested the dll on windows mac=
hine with pythonnet and it’s working fine.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p> </o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">Best Regards<o:p></o:p></span><=
/p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">Hossam Alzomor<o:p></o:p></span=
></p>
</div>
<br>
<img src=3D"https://www.elmos.com/mailfooter/email_footer_izb_2022_new.jpg"=
alt=3D"IZB Wolfsburg 2022 | Hall 2 | Booth 2405 | 11 - 13 Oct, 2022 | Wol=
fsburg" width=3D"287" height=3D"131" border=3D"0"><br>
</body>
</html>
--_000_364cacdf21084613be914d2d7141ed6amechalesscom_--
--===============7337929025948025280==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
PythonNet mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/pythonnet.python.org/
Member address: [email protected]
--===============7337929025948025280==--