c# mono interop - 无法识别的配置部分 dllmap

c# mono interop - Unrecognized configuration section dllmap

我明白了:当我把 dllmap 放入 app.config 以便单声道可以找到本机 dll 的 linux 风格时,我打乱了基于 windows 的配置系统因为没有为其定义配置部分。

我可以看到我有一些选择:

所以问题是,如何消除 windows 上的错误?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
    </startup>
    <dllmap dll="winscard" target="libpcsclite.so.1"/>
</configuration>

错误:

Configuration system failed to initialize

Unrecognized configuration section dllmap. (...exe.Config line 6)

很好 someone else has asked this before,但对我没有帮助。

我想,如果将互操作部分移动到一个单独的程序集文件(exe 除外),那么我们可以有一个专门用于该 dll (your.dll.config) 的配置文件,它将被 MS 忽略框架,但由单声道解析。实际上,这解决了我的问题。我不确定这是否是最好的解决方案,但它是可以接受的。

运行:

MONO_LOG_LEVEL=debug mono my.exe

非常有帮助,因为它在加载库时显示了单声道 at/for 的内容,所以我看到它正在寻找 dll.config。