Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Visual Studio 2012中的DllImport方法引发错误_C#_Visual Studio_Dll_Dllimport - Fatal编程技术网

C# Visual Studio 2012中的DllImport方法引发错误

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)

我试图将DLL导入到我的项目中,但它一直将代码视为存在语法错误。这没有意义,因为我使用的是网站上的示例代码。我只是想看看它是否有效,但没有。代码如下:

[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");
 }
}

它说我缺少一个
。它说我缺少一个
。谢谢你的帮助。结果是我把它放在了另一个方法中。很抱歉问了这个蹩脚的问题。谢谢你的帮助。结果是我把它放在了另一个方法中。对不起,我问了个蹩脚的问题。