简体   繁体   English

Xamarin Linker 删除对第三方的引用 dll

[英]Xamarin Linker removing reference to third party dll

When running my app in Release mode in Xamarin I get the following error with 'Link SDK assemblies only' on:在 Xamarin 中以 Release 模式运行我的应用程序时,出现以下错误,并显示“仅链接 SDK 程序集”:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Error executing task LinkAssemblies: error XA2006: Reference to metadata item 'System.IO.Ports.SerialPort' (defined in 'EftPay, Version=1.2.0.0, Culture=neutral, PublicKeyToken=e6147cbb02cecb0d') from 'EftPay, Version=1.2.0.0, Culture=neutral, PublicKeyToken=e6147cbb02cecb0d' could not be resolved. /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Error executing task LinkAssemblies: error XA2006: Reference to metadata item 'System.IO.Ports.SerialPort'(定义在“EftPay,Version=1.2.0.0,Culture=neutral,PublicKeyToken=e6147cbb02cecb0d”中)来自“EftPay,Version=1.2.0.0,Culture=neutral,PublicKeyToken=e6147cbb02cecb0d”无法解析。 (mPOS) (mPOS)

I am using a third-party library that uses the SerialPort reference in a class (as seen in the error), however, I do not use that specific class. Is there a way I can tell the linker to not strip this reference?我正在使用第三方库,该库使用 class 中的 SerialPort 引用(如错误中所示),但是,我不使用该特定的 class。有没有办法告诉 linker 不要删除此引用?

Thanks for any help.谢谢你的帮助。

Did you tried to create a static class that "uses" SerialPort class?您是否尝试创建一个“使用”SerialPort class 的 static class? Something similar to this: https://github.com/MvvmCross/MvvmCross/blob/v3/nuspec/DroidContent/LinkerPleaseInclude.cs.pp类似于此: https://github.com/MvvmCross/MvvmCross/blob/v3/nuspec/DroidContent/LinkerPleaseInclude.cs.pp

Or you could try to LinkSkip that assembly或者您可以尝试 LinkSkip 该程序集

<PropertyGroup>
     <AndroidLinkSkip>Assembly1;Assembly2</AndroidLinkSkip>
</PropertyGroup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM