[英]How can I use dllmap on Xamarin.Android and Xamarin.iOS?
I'm using Xamarin.Android, have a project set up like so 我正在使用Xamarin.Android,有一个像这样的项目设置
Using mono, one could simply use dllmap in App.config to remap any DllImports to NativeMethods.dll to NativeMethods.so 使用mono,可以简单地在App.config中使用dllmap将任何DllImports重新映射到NativeMethods.dll到NativeMethods.so
I tried, but I can't seem to get this working with Xamarin.Android. 我尝试过,但我似乎无法使用Xamarin.Android。 I'd like to avoid compiling two MSIL P/Invoke libraries as well as two native ones (one each for Android and Windows).
我想避免编译两个MSIL P / Invoke库以及两个本机库(Android和Windows各一个)。
Here's what my app.config looks like 这是我的app.config的样子
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<dllmap dll="NativeMethods.dll" target="NativeMethods.so"/>
</configuration>
I tried this in the P/Invoke DLL project, the Xamarin.Android application project but it doesn't work anywhere. 我在P / Invoke DLL项目,Xamarin.Android应用程序项目中尝试了这个,但它在任何地方都不起作用。 The only reference I found to my issue is this similar one for iOS.
我发现我的问题的唯一参考是这类似一个用于iOS系统。 Has anyone encountered/solved this issue?
有没有人遇到/解决了这个问题? What am I missing?
我错过了什么? I'd also be interested if the solution to do this for Xamarin.iOS was any different, because that will be the next platform I need to target.
如果为Xamarin.iOS执行此操作的解决方案有任何不同,我也会感兴趣,因为这将是我需要定位的下一个平台。
Thanks in advance! 提前致谢!
Use NativeMethods
(without extension) as the name of the library. 使用
NativeMethods
(不带扩展名)作为库的名称。
.NET will automatically append .dll
and Mono will automatically append .so
when searching for the library. .NET将自动附加
.dll
,Mono将在搜索库时自动附加.so
。
However for iOS you'll need a dllmap (since the library name must be __Internal
) 但是对于iOS,你需要一个dllmap(因为库名必须是
__Internal
)
Source: http://www.mono-project.com/docs/advanced/pinvoke/ 资料来源: http : //www.mono-project.com/docs/advanced/pinvoke/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.