C#不承认SafeTokenHandle

Siw*_*hit 4 c# windows permissions

我有一个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);
Run Code Online (Sandbox Code Playgroud)

在*符号(LogonUser的和SafeTokenHandle)字.由于类型未知,我的C#编译器无法编译.我开发了visual studio 2012,windows 64,framework 4.0.

请帮忙.

arg*_*gaz 9

SafeTokenHandle不是.Net框架的一部分.我假设您的代码与本文有些相关,所以您错过了定义:

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);
    }
}
Run Code Online (Sandbox Code Playgroud)