DLLimport

  • Thread starter Thread starter farseer
  • Start date Start date
F

farseer

i am trying to include the following P/Invoke function in a class:
[DllImport("coredll.dll")]
private static extern bool TerminateProcess(IntPtr hProcess,
uint ExitCode);

this is based on an MSDN article found here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/ProcessManager.asp

the problem is when i try to compile, i get the error "The type or
namespace name 'DllImport' could not be found (are you missing a using
directive or an assembly reference?"

the project is a Pocket PC 2003 project.

any ideas how to successfully get this going?
 
Are you missing the "using" directive?

using System.Runtime.Interop

Please, read the error messages. Most of them are informative, sometimes to
a fault
 
i don't believe a using is needed with DLLImports. the error indicates
it cannot find the specified dll, but i did find that dll on my system
at the following locations:

what i did to solve this was change my device from "Pocket PC 2003 SE
Emulator" to "Pocket PC 2003 Device"
 
i was wrong...though i thought for sure changing the taget device
worked....it is not working anymore.

so i am not sure why i can't compile. i see that the DLLs it is
referencing do exist on my system (one in System32, so should be in the
path). i am wondering if this needs to be set somewhere in the
emulator i am using and if so, how do i do this?
 
No, you *must* have a "using System.Runtime.InteropServices" at the top of
the code page. That's what the error is telling you.

-Chris
 
Back
Top