I have a compilation error with C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Security.Principal;
using System.Security.Permissions;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
[DllImport("advapi32.dll", SetLastError = true,CharSet = CharSet.Unicode)]
public static extern bool ***LogonUser***(string lpszUsername, string lpszDomain, string lpszPassword,
int dwLogonType, int dwLogonProvider, out ***SafeTokenHandle*** phToken);
In the word at the * sign (LogonUser and SafeTokenHandle). My C# compiler can not compile because of unknown type. I develop with visual studio 2012, windows 64, framework 4.0.
Please Help.
SafeTokenHandle
is not part of the .Net framework. I'm assuming your code is somewhat related to this article, So you're missing the definition:
public sealed class SafeTokenHandle : SafeHandleZeroOrMinusOneIsInvalid
{
private SafeTokenHandle()
: base(true)
{
}
[DllImport("kernel32.dll")]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool CloseHandle(IntPtr handle);
protected override bool ReleaseHandle()
{
return CloseHandle(handle);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With