我正在使用C#在.NET 4.0框架(beta2)上创建一个Web应用程序.
当我尝试使用名为"ActiveHomeScriptLib"的程序集时,出现以下错误:
无法嵌入Interop类型'ActiveHomeScriptLib.ActiveHomeClass'.请改用适用的界面.
当我将框架更改为3.5版时,我没有任何错误.
什么是互操作类型,为什么只有在我使用4.0框架时才会出现这种情况?
我正在使用WIA将扫描仪的图像捕获到窗体.这是我正在使用的代码:
private void button2_Click(object sender, EventArgs e)
{
const string wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}";
CommonDialogClass wiaDiag = new CommonDialogClass();
WIA.ImageFile wiaImage = null;
wiaImage = wiaDiag.ShowAcquireImage(
WiaDeviceType.UnspecifiedDeviceType,
WiaImageIntent.GrayscaleIntent,
WiaImageBias.MaximizeQuality,
wiaFormatJPEG, true, true, false);
WIA.Vector vector = wiaImage.FileData;
Image i = Image.FromStream(new MemoryStream((byte[])vector.get_BinaryData()));
i.Save(@"D:\prueba1.jpeg");
}
Run Code Online (Sandbox Code Playgroud)
当尝试运行这个小测试时,我收到此错误:
无法嵌入Interop类型'WIA.CommonDialogClass'.请改用适用的界面.
还有这个:
'WIA.CommonDialogClass'不包含'ShowAcquireImage'的定义,也没有接受第一个类型'WIA.CommonDialogClass'的扩展方法'ShowAcquireImage'(你是否缺少using指令或汇编引用?
我猜第二个错误是由于第一个错误而上升,对吧?
对于如何解决这个问题,有任何的建议吗?