互操作类型不能被嵌入 [英] Interop type cannot be embedded

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

问题描述

我创建在C#中的.NET 4.0框架(β2)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".

编辑:又见迈克尔Gustus的回答,从你使用的类型删除后缀

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

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

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