如何在mac osx上使用mono C#调用* .framework [英] How to p/invoke *.framework with mono C# on mac osx
问题描述
我一直在尝试使用C#在Mac上调用* .framework文件,但总是得到一个DllNotFoundException。
我试图按照本指南但没有运气。
.framwork文件位于应用程序旁边的子文件夹中。
配置文件如下所示:
I've been trying to P/Invoke a *.framework file on a mac with C# but always get a DllNotFoundException.
I tried to follow this guide but no luck.
The .framwork file is in a subfolder right beside the application.
The config file looks like this:
<configuration>
<dllmap dll="MacLib" target="Subfolder/Lib.framework" />
</configuration>
和P / Invoke代码:
and the P/Invoke code:
[DllImport("MacLib")]
private static extern void SomeMethod();
我知道mac上的区分大小写,所以这不是问题所在。 />
我也尝试将.framework文件放入mac framworks文件夹但是也没用。
我不是很有经验在Mac上单声道,所以我可能会忽略一些明显的东西。
希望你能在这里帮助我。
提前谢谢
Johannes
I know about the case sensitivity on mac, so that's not the problem.
I also tried to put the .framework file into the mac framworks folder but that didn't work either.
I'm not very experienced with mono on mac so I might overlook something obvious.
Hope you can help me out here.
Thank you in advance
Johannes
推荐答案
最好的推荐的方法是使用它:
The best and recommended way is to use this:
[DllImport("@executable_path/../Frameworks/EDSDK.framework/EDSDK")]
框架文件应位于Frameworks文件夹中并与DllImport一起使用属性你使用标准C#而不是一些Mono xml-config。
确定我发现了问题。有三种方法:
1.计算机/图书馆/框架/文件夹中的框架:
适用于图书馆和应用程序。
配置文件必须如下所示:
The framework files should be in the Frameworks folder and with the DllImport attribute you use standard C# and not some Mono xml-config.
ok I found the problem. There are three ways:
1. framework in the computers /Library/Frameworks/ folder:
Works for libraries as well as apps.
The config file has to look like this:
<configuration>
<dllmap dll="MacLib" target="Lib.framework/Lib" />
</configuration>
2.应用程序内的框架:
仅适用于一个应用程序。
配置文件必须如下所示:
2. framework within the app:
Works only for an app.
The config file has to look like this:
<configuration>
<dllmap dll="MacLib" target="@executable_path/../Frameworks/Lib.framework/Lib" />
</configuration>
然后你必须将框架放入* .app。如果没有,请在Contents文件夹中创建一个名为Frameworks的文件夹,并将.framwork放入其中。
3.应用程序旁边的框架(或在app旁边的子文件夹中):
适用于图书馆和应用程序。
配置文件必须如下所示:
Then you have to put the framework into the *.app. If not there already, create a folder called "Frameworks" in the "Contents" folder and put the .framwork in it.
3. framwork beside the app (or in subfolder beside app):
Works for libraries as well as apps.
The config file has to look like this:
<configuration>
<dllmap dll="MacLib" target="@executable_path/../../../Lib.framework/Lib" />
</configuration>
如果框架位于库/ app旁边的子文件夹中,请相应地更改路径。
eg @executable_path /../../../ Subfolder / Lib.framework / Lib
也许有帮助别人也是。
亲切的问候
Johannes
If the framework is in a subfolder beside the library/app, change the path accordingly.
e.g. @executable_path/../../../Subfolder/Lib.framework/Lib
Maybe that helps someone else too.
Kind regards
Johannes
这篇关于如何在mac osx上使用mono C#调用* .framework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!