c# - 警告 MSB3290:无法为类型库创建包装程序集
问题描述
我试图添加 System_Windows_Forms 参考 COM 参考。但是当我添加它时,我得到了这个错误
Microsoft.Common.CurrentVersion.targets(2701,5): warning MSB3290: Failed to create the wrapper assembly for type library "{215d64d2-031c-33c7-96e3-61794cd1ee61}". Type library 'System_Windows_Forms' was exported from a CLR assembly and cannot be re-imported as a CLR assembly.
顺便说一句,我在控制台应用程序上,出于某种原因,我没有看到一个节点,而是看到了Reference
一个Dependencies
节点,尽管我怀疑这很重要。
我也尝试添加不同的参考,Interop.IWshRunTimeLibrary
有效,但System.Drawing.dll
没有
解决方案
如果您正在运行控制台应用程序,您将无法引用或加载System.Windows.Forms
依赖项。同样,这些与对象System.Drawing
直接相关,因此不能作为控制台依赖项访问,这就是您收到该错误的原因。Form
Form
更新:要检查控制台应用程序中的按键,请使用Console.Readkey()
方法。这是一个使用示例Console.ReadKey()
using System;
class CheckKeyPress
{
public static void Main()
{
ConsoleKeyInfo cki;
Console.TreatControlCAsInput = true; //Prevents from ending if CTL+C is pressed
Console.Writeline("Press any CTL, ALT, or SHIFT");
Console.Writeline("Press ESC key to quit: \n");
do
{
cki = Console.ReadKey();
Console.Write("You Pressed: ");
if ((cki.Modifiers & ConsoleModifiers.ALT) != 0) Console.Write("ALT+");
if ((cki.Modifiers & ConsoleModifiers.SHIFT) != 0) Console.Write("SHIFT+");
if ((cki.Modifiers & ConsoleModifiers.CTL) != 0) Console.Write("CTL+");
Console.WriteLine(cki.Key.ToString());
} while (cki.Key != ConsoleKey.Escape);
}
}
推荐阅读
- ansible - 如何从 tar.gz 文件安装 Ansible Galaxy 角色?
- mysql - SQL 数据库在 SELECT 中冻结超过 7 个 JOIN [查询需要永远加载]
- node.js - 使用 EventSource 时 504 网关超时 240000 毫秒
- go - 自动重新加载配置
- python - 尝试在 heroku 上使用 pdf2image 时出错:libpng12.so.0:无法打开共享对象文件:没有这样的文件或目录
- performance - 请求内容大小和请求时长有什么关系
- angular - 迭代器上的角循环
- c# - 当我在类派生形式的接口中调用它时,为什么我需要将“this”转换为具有 C# 8.0 中默认实现的接口?
- javascript - 升级到 Angular 10 后无法读取未定义的属性“0”中的错误
- angular - 将rest api promise请求转换为角度离子中的rxjs请求