<p>I need to call an external dll from c#. This is the header definition:</p>

<pre><code>enum WatchMode { 
   WATCH_MODE_SYSTEM = 0,          
   WATCH_MODE_APPLICATION  = 1 };  

LONG ADS_API WDT_GetMode ( LONG i_hHandle, WatchMode * o_pWatchMode );
</code></pre>

<p>I've added the enum and the call in C#:</p>

<pre><code>public enum WatchMode
{
    WATCH_MODE_SYSTEM = 0,
    WATCH_MODE_APPLICATION = 1       
}
[DllImport("AdsWatchdog.dll")]
internal static extern long WDT_GetMode(long hHandle, ref WatchMode watchmode);
</code></pre>

<p>This generates an AccessViolationException. I know the dll is 'working' because I've also added a call to <code>GetHandle</code> which returns the <code>hHandle</code> mentioned above. I've tried to change the param to an <code>int</code> (<code>ref int watchmode</code>) but get the same error. Doesn anyone know how I can PInvoke the above call?</p>

You're running into a parameter size problem difference between C# and C++.  In the C++/windows world LONG is a 4 byte signed integer.  In the C# world long is a 8 byte signed integer.  You should change your C# signature to take an int.
ffpf is wrong in saying that you should use an IntPtr here.  It will fix this particular problem on a 32 bit machine since an IntPtr will marshal as a int.  If you run this on a 64 bit machine it will marshal as a 8 byte signed integer again and will crash.