In one STATIC class (my helper class named AutoItX3Delcarations.cs
) i have wrapped up a dll like so:
//AU3_API void WINAPI AU3_Send(LPCWSTR szSendText, /*[in,defaultvalue("")]*/long nMode);
[DllImport("AutoItX3.dll", SetLastError = true, CharSet = CharSet.Auto)]
static public extern void AU3_Send([MarshalAs(UnmanagedType.LPWStr)] string SendText, int Mode);
Basically, creating a static method within a static class.
Now, in my main program execution I attempt to perform this method like so:
AutoItX3Declarations.AU3_Send("Test Text", 1);
which, by the MSDN should work...? But it doesn't! I have attempted to search through here and on google for about an hour but can't see why this isn't working.. I am calling the method by using it's class as the location and then the function as brought in by DLL import.
The error i get is "....AU3_Send(string,int)' is a 'method' but is used like a 'type' " ...
But how am i using it as a type?? I thou开发者_JAVA百科ght this is how you correctly call a static method?
Please help :(
Are you sure your method call is within the body of a method? If you could post the surrounding code, that would help.
For example, this should compile fine:
static void Foo()
{
AutoItX3Declarations.AU3_Send("Test Text", 1);
}
I suggest you try that, just to confirm that it really is the call context rather than the method declaration which is causing the problem (although I fully expect that's the case).
精彩评论