无法嵌入互操作类型 [英] Interop type cannot be embedded

查看:32
本文介绍了无法嵌入互操作类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 C# 在 .NET 4.0 框架 (beta2) 上创建一个 Web 应用程序.

I am creating a web application on the .NET 4.0 framework (beta2) in C#.

当我尝试使用名为ActiveHomeScriptLib"的程序集时,出现以下错误:

When I try to use a assembly called "ActiveHomeScriptLib", I get the following error:

互操作类型'ActiveHomeScriptLib.ActiveHomeClass'无法嵌入.使用适用的代替界面.

Interop type 'ActiveHomeScriptLib.ActiveHomeClass' cannot be embedded. Use the applicable interface instead.

当我将框架更改为 3.5 版时,我没有任何错误.

When I change the framework to version 3.5, I don't have any errors.

什么是互操作类型,为什么只有在我使用 4.0 框架时才会出现这种情况?

What is an Interop Type and why does this only occur when I use the 4.0 framework?

推荐答案

.NET 4.0 允许将主要互操作程序集(或者更确切地说,您需要的部分)嵌入到您的程序集中,这样您就不需要将它们与您的应用程序一起部署.

.NET 4.0 allows primary interop assemblies (or rather, the bits of it that you need) to be embedded into your assembly so that you don't need to deploy them alongside your application.

无论出于何种原因,无法嵌入此程序集 - 但听起来这对您来说不是问题.只需在 Visual Studio 2010 中打开程序集的属性"选项卡,并将嵌入互操作类型"设置为假".

For whatever reason, this assembly can't be embedded - but it sounds like that's not a problem for you. Just open the Properties tab for the assembly in Visual Studio 2010 and set "Embed Interop Types" to "False".

另请参阅 Michael Gustus 的 answer,从您的类型中删除 Class 后缀正在使用.

See also Michael Gustus's answer, removing the Class suffix from the types you're using.

这篇关于无法嵌入互操作类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆