Reputation: 41
I have a problem with my compiler not being able to import kernel32.dll, althrough I'm using System.Runtime.InteropServices. Here is the Code:
using System;
...
using System.Runtime.InteropServices;
namespace server
{
class Debugconsole
{
public void Initialise()
{
[DllImport("kernel32.dll")]
...
}
}
}
It throws a whole bunch of syntaxerrors and "Can't find "DllImport" in current context."
Thanks for your help.
Upvotes: 1
Views: 1050
Reputation: 14059
Attributes cannot be used inside a method.
You should move it out of your method:
class Debugconsole
{
[DllImport("kernel32.dll")]
... the static extern method declaration ...
public void Initialise()
{
...
}
}
Upvotes: 2