Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling C++ dll from C# - how to debug?
Message
 
 
To
21/10/2017 07:52:16
General information
Forum:
C#
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01655067
Message ID:
01655190
Views:
61
It does work OK for me locally. However, for our QA server it returns

ww_local.dll generated an exception..Unable to load DLL 'C:\Program Files (x86)\Siriusware\Pool\ww_local.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Do you know what may be wrong - some dependent dlls are missing or it may be something else?

Also, I think I tried to use DllImport without specifying the exact path and got similar exception. But I don't want to use hardcoded path and as I understood I can not use dynamic path here.

What would be the best workaround?

UPDATE. I re-tested by placing all dlls into bin/debug folder. It didn't work for me. Looks like I do need to hardcode the path?

UPDATE 2. After placing all dlls into debug folder for the Test project I was able to debug my test OK. So, I assume it should work fine without specifying the paths. I'm going to re-test it.

>>I got it to work! Thanks a million for your help.
>>
>>This is how it's declared now:
>>
>>
>> [DllImport(@"C:\Program Files (x86)\Siriusware\Pool\ww_local.dll",
>>            ExactSpelling = false,
>>            CallingConvention = CallingConvention.Cdecl,
>>            CharSet = CharSet.Ansi)]
>>        static extern IntPtr Invoke1( String str);
>>
>>
>>And this is how I call it:
>>
>>  translate = Marshal.PtrToStringAnsi(Invoke1(invoke));
>
>
>Good.
>
>That how a string is returned
>The dll returns a pointer to a string, hence IntPtr in the declaration
>Once it returns, you create a string with PtrToStringAnsi
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform