最新消息:20181230 VPS服务器已从Linode换到腾讯云香港,主题仍用朋友推荐的大前端D8

【已解决】error CS0246: The type or namespace name ‘DllImport’ could not be found (are you missing a using directive or an assembly reference?)

C# crifan 2239浏览 0评论

【问题】

C#程序中,有类似这样代码:

// Registers a hot key with Windows.
[DllImport("user32.dll")]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);

编译后出错:

D:\xxx\downloadSongtasteMusic\frmDownloadSonstasteMusic.cs(15,10): error CS0246: The type or namespace name ‘DllImport’ could not be found (are you missing a using directive or an assembly reference?)

【解决过程】

1.参照:C# 小结 二,添加了:

using System.Runtime.InteropServices;

然后就解决了。

转载请注明:在路上 » 【已解决】error CS0246: The type or namespace name ‘DllImport’ could not be found (are you missing a using directive or an assembly reference?)

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
67 queries in 0.068 seconds, using 9.52MB memory