C# Visual Studio 2012中的DllImport方法引发错误
我试图将DLL导入到我的项目中,但它一直将代码视为存在语法错误。这没有意义,因为我使用的是网站上的示例代码。我只是想看看它是否有效,但没有。代码如下:C# Visual Studio 2012中的DllImport方法引发错误,c#,visual-studio,dll,dllimport,C#,Visual Studio,Dll,Dllimport,我试图将DLL导入到我的项目中,但它一直将代码视为存在语法错误。这没有意义,因为我使用的是网站上的示例代码。我只是想看看它是否有效,但没有。代码如下: [DllImportAttribute("KERNEL32.DLL", EntryPoint="MoveFileW",SetLastError=true,CharSet=CharSet.Unicode, ExactSpelling=true, CallingConvention=CallingConvention.StdCall)
[DllImportAttribute("KERNEL32.DLL", EntryPoint="MoveFileW",SetLastError=true,CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool MoveFile(String src, String dst);
有人能给我解释一下发生了什么吗?也许你可以在这里发布完整的源代码和错误消息 此测试程序可编译并正常运行:
using System;
using System.Runtime.InteropServices;
class App
{
[DllImportAttribute("KERNEL32.DLL", EntryPoint="MoveFileW",SetLastError=true,CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool MoveFile(String src, String dst);
static void Main()
{
MoveFile("import.cs","D:\\aa.cs");
}
}
也许您可以在这里发布完整的源代码和错误消息 此测试程序可编译并正常运行:
using System;
using System.Runtime.InteropServices;
class App
{
[DllImportAttribute("KERNEL32.DLL", EntryPoint="MoveFileW",SetLastError=true,CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool MoveFile(String src, String dst);
static void Main()
{
MoveFile("import.cs","D:\\aa.cs");
}
}
它说我缺少一个
代码>。它说我缺少一个代码>。谢谢你的帮助。结果是我把它放在了另一个方法中。很抱歉问了这个蹩脚的问题。谢谢你的帮助。结果是我把它放在了另一个方法中。对不起,我问了个蹩脚的问题。