Metadata file ´c:\Windows\System32\shell32.dll´ could not be opened -- ´An attempt was made to load a program with an incorrect format.´
of course I added the dll in the project… no success. google suggest its related to the systemarchitecture x86 or 64bit…
I´m using 45beta32.1 x86
any ideas?
hi,
is it a mamanged or a unmanaged dll? If it is a unmanaged you can’t add it as dependency via Project-Expolerer. You have to call the funcitons from the dll via System.Runtime.InteropServices.
thanks for your quick reply.
aparently its unmanaged. I was able to import the dll the way you suggested. I see how I can call the function but not how I can assign a variable of a type defined in the required dll.
Is there a way to use these types, so I could write:
not quite sure if i understand your question and i’m not very experienced in c# either, however,
if your looking to retrieve whatever the function returns it works for me like that (given the return type is e.g. an int)
int return = yourDLLFunction ();
if the function in the dll you are calling has parameters, and you intend/have to set these you need to specify these parameters first at the dll import
System.Runtime.InteropServices.DllImport("yourDLL.dll")]
private static extern int yourDLLFunction(int param1);
and then call the function inside evaluate like:
int myParam = 0;//change here to your needs
int return = yourDLLFunction(myParam);
i can’t give a lot of insight in that code, but i can testify it wotks ;)
it’s a little more complicated if the argument of your imported function is a c++ pointer like
System.Runtime.InteropServices.DllImport("yourDLL.dll")]
private static extern int yourDLLFunction(char* Name);
then you will have to use delegates/marshalling, allocate buffers and so on, trying to figure that out atm ;) any help with that very appreciated too…