Laurent,

Ah, I'd used @executable_path in a dll.config, it hadn't occurred to
me that it could also be passed to DllImportAttribute.

If I switch my DllImport parameter to use @executable_path/../..., I
can successfully call the unmanaged methods when running my
application as a standalone app bundle, however, it no longer works
when running from a non-standalone app build.

If I can use the same string for both configurations, that would
obviously be ideal. As it is now, I'll probably set up a try/catch
fallback so that I can operate in both configurations.

Thanks,

--Anthony

On Wed, Mar 17, 2010 at 1:56 AM, Laurent Etiemble
<laurent.etiem...@monobjc.net> wrote:
> Hello,
> If you only want to load the framework (to register some classes), you can
> use the ObjectiveCRuntime.LoadFramework method. It is able to pick private
> framework within an application bundle.
> If you want to access a function within the private framework, then you have
> to use the @executable_path tag in the DllImport attribute.
> th...@executable_path will be expanded at runtime by the dylib loader and
> will refer to the path of the executable. Monobjc uses this trick to be able
> to load at runtime its native library. In you case, the DllImport tag will
> look like:
> [DllImport("@executable_path/../Frameworks/Foo.framework/Foo", ...)]
> Regards, Laurent Etiemble.
>
> 2010/3/17 anthony taranto <anthony.tara...@gmail.com>
>>
>> Here's the mono output when running my standalone app with
>> MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll"
>>
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport attempting to load:
>> 'Contents/Frameworks/Foo.framework/Foo'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading location:
>> 'libContents/Frameworks/Foo.framework/Foo.dylib'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library:
>> 'dlopen(libContents/Frameworks/Foo.framework/Foo.dylib, 9): image not
>> found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading location:
>> 'libContents/Frameworks/Foo.framework/Foo.so'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library:
>> 'dlopen(libContents/Frameworks/Foo.framework/Foo.so, 9): image not
>> found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading location:
>> 'libContents/Frameworks/Foo.framework/Foo.bundle'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library:
>> 'dlopen(libContents/Frameworks/Foo.framework/Foo.bundle, 9): image not
>> found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading library:
>> './libContents/Frameworks/Foo.framework/Foo.dylib'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library
>> 'dlopen(./libContents/Frameworks/Foo.framework/Foo.dylib, 9): image
>> not found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading library:
>> './libContents/Frameworks/Foo.framework/Foo.so'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library
>> 'dlopen(./libContents/Frameworks/Foo.framework/Foo.so, 9): image not
>> found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading library:
>> './libContents/Frameworks/Foo.framework/Foo.bundle'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library
>> 'dlopen(./libContents/Frameworks/Foo.framework/Foo.bundle, 9): image
>> not found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading: 'Contents/Frameworks/Foo.framework/Foo'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library
>> 'dlopen(Contents/Frameworks/Foo.framework/Foo, 9): image not found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading location:
>> 'libContents/Frameworks/Foo.framework/Foo.dylib'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library:
>> 'dlopen(libContents/Frameworks/Foo.framework/Foo.dylib, 9): image not
>> found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading location:
>> 'libContents/Frameworks/Foo.framework/Foo.so'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library:
>> 'dlopen(libContents/Frameworks/Foo.framework/Foo.so, 9): image not
>> found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading location:
>> 'libContents/Frameworks/Foo.framework/Foo.bundle'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library:
>> 'dlopen(libContents/Frameworks/Foo.framework/Foo.bundle, 9): image not
>> found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading library:
>> './libContents/Frameworks/Foo.framework/Foo.dylib'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library
>> 'dlopen(./libContents/Frameworks/Foo.framework/Foo.dylib, 9): image
>> not found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading library:
>> './libContents/Frameworks/Foo.framework/Foo.so'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library
>> 'dlopen(./libContents/Frameworks/Foo.framework/Foo.so, 9): image not
>> found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading library:
>> './libContents/Frameworks/Foo.framework/Foo.bundle'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library
>> 'dlopen(./libContents/Frameworks/Foo.framework/Foo.bundle, 9): image
>> not found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport loading:
>> 'libContents/Frameworks/Foo.framework/Foo'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> Mono-INFO: DllImport error loading library
>> 'dlopen(libContents/Frameworks/Foo.framework/Foo, 9): image not
>> found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> (MyProject.exe:9524): Mono-WARNING **: DllImport unable to load
>> library 'dlopen(libContents/Frameworks/Foo.framework/Foo, 9): image
>> not found'.
>> 3/16/10 6:55:02 PM [0x0-0xe33e33].com.MyCompany.MyProject[9524]
>> System.DllNotFoundException: Contents/Frameworks/Foo.framework/Foo
>>
>>
>> On Tue, Mar 16, 2010 at 6:42 PM, anthony taranto
>> <anthony.tara...@gmail.com> wrote:
>> > Hello,
>> >
>> > I'm going to ship a custom framework in my monobjc application's app
>> > bundle. This framework is located at
>> > "Contents/Frameworks/Foo.framework/Framework".
>> >
>> > When I build a _non_ standalone application bundle (mkappl), i'm able
>> > to successfully invoke methods in this framework using
>> > [DllImport("Contents/Frameworks/Foo.framework/Framework")]. However.
>> > when I build a standalone application bundle (mkbundle, mkappl), the
>> > DllImport fails to find the correct directory.
>> >
>> > How should I arrange things so that I can load this framework from
>> > both standalone and non standalone application bundles? Is there some
>> > relative path or dllmap magic that I'm missing?
>> >
>> > Thanks.
>> >
>> > --Anthony
>> >
>
>

Reply via email to