When interfacing with .NET, how do I use unmanaged DLLs that are located in the assembly folder?

Hi,
I'm calling some functions in a .NET assembly that is in a different folder to MATLAB. I'm aware that using dllimport for unmanaged DLLs doesn't work in this case because matlab.exe is in a different folder. Copying the unmanaged DLLs to the MATLAB installation folder works, but this is not an ideal solution for production code.
Is there a way to get around this problem without hard-coding directories? I'm trying to avoid editing the Windows path.
Thanks
James

 採用された回答

Friedrich
Friedrich 2013 年 12 月 6 日
編集済み: Friedrich 2013 年 12 月 10 日
Hi,
you can edit the PATH locally for MATLAB only with the setenv command:
setenv('PATH',[getenv('PATH'),';C:\your folder with DLLs'])
So you can build up the PATH dynamically at runtime and set it silently in the background.
UPDATED TYPO (Thanks James)

1 件のコメント

Thanks very much! Though I used
getenv('PATH')
instead of
get('PATH')

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2013 年 12 月 6 日

編集済み:

2013 年 12 月 10 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by