1

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 thought this is how you correctly call a static method?

Please help :(

1
  • Please post the code surrounding your method call. Commented Nov 25, 2010 at 8:32

1 Answer 1

7

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).

Sign up to request clarification or add additional context in comments.

1 Comment

Wow... I had no idea that the method call had to be within the body of a method.. I was just testing it out in the body of my main form class. I moved it over to a method in my main threading class and compiles fine now.... Hmmm seems like an easy mistep and stupid.. sorry all!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.