Interop type cannot be embedded
来源:互联网 发布:php权限管理 编辑:程序博客网 时间:2024/05/14 07:10
http://stackoverflow.com/questions/2483659/interop-type-cannot-be-embedded
6 down vote favorite
1
I am creating an web application on the .net 4.0 framework (beta2 ) in C#.
When I try to use a assembly called "ActiveHomeScriptLib", I get the following error:
Interop type 'ActiveHomeScriptLib.ActiveHomeClass' cannot be embedded. Use the applicable interface instead.
When I change the framework to version 3.5, I don't have any errors.
What is an Interop Type and why does this only occur when I use the 4.0 framework.
visual-studio-2010 c#4.0
link|flag
asked Mar 20 at 15:47
Jan
20510
70% accept rate
3 Answers
oldest newest votes
up vote 8 down vote accepted
.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.
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".
Btw, I'd thoroughly recommend upgrading from VS2010b2 to the release candidate - it's much, much faster and more stable too, in my experience.
link|flag
answered Mar 20 at 15:54
Jon Skeet
218k407901657
Thanks, changing the property was just what I wanted but I couldn't found it. – Jan Mar 20 at 16:12
up vote 2 down vote
Expanding on Jon's correct answer.
The problem here is that your are combining the new "Embed Interop Types" (or NoPIA) feature with use of a class type. The "Embed Interop Types" feature works by essentially statically linking in all of the types from a PIA (Primary Interop Assembly) into the referencing assembly removing the overhead of deploying it.
This feature works great for most types in a PIA but it does have restrictions. One of them is that you cannot embed classes (it's a servicing issue). Misha has a detailed blog article on why this is not allowed
· http://blogs.msdn.com/mshneer/archive/2009/12/07/interop-type-xxx-cannot-be-embedded-use-the-applicable-interface-instead.aspx
link|flag
answered Mar 20 at 17:42
JaredPar
114k15195429
up vote 1 down vote
Like Jan It took me a while to get it .. =S So for anyone else who's blinded with frustration. Right click the offending assembly that you added in the solution explorer (I my case WIA) and then click properties. And there should be the option there for Embed Interop Assembly.
- Interop type cannot be embedded
- Interop type 'Microsoft.Office.Interop.Outlook.ApplicationClass' cannot be embedded. Use the applica
- Interop type 'Microsoft.Office.Interop.Word.ApplicationClass' cannot be embedded. Use the applicable
- Interop type 'Microsoft.Office.Interop.Excel.ApplicationClass' cannot be embedded. Use th e applic
- 错误:Interop type 'ADOX.CatalogClass' cannot be embedded. Use the applicable interface instead
- Bug:Interop type 'mshtml.HTMLDocumentClass' cannot be embedded. Use the applicable interface instead
- Bug:Interoptype 'Microsoft.Office.Interop.Excel.WorkbookClass' cannot be embedded. Use theapplicable
- Cannot determine embedded database driver class for database type NONE
- Cannot determine embedded database driver class for database type NONE
- Cannot determine embedded database driver class for database type NONE
- Cannot determine embedded database driver class for database type NONE
- Cannot determine embedded database driver class for database type NONE
- Cannot determine embedded database driver class for database type NONE.
- Cannot determine embedded database driver class for database type NONE
- 怎么解决Excel.ApplicationClass' cannot be embedded问题?
- Embedded statement cannot be a declaration or labeled statement
- cannot be resolved to a type解决方案
- The type XXX cannot be resolved
- SameTime8.5 新特性
- 敏捷宣言
- 菊花文和边框文的实现
- evc 长按左键消息
- 关于Java变量标识符的命名规范
- Interop type cannot be embedded
- 微软云计算服务 - Microsoft SharePoint Online
- 八叉树
- tomcat 日志 log4配置
- Spring+iBatis多数据源的动态配置方案
- jdbc连接数据库驱动
- .net学习笔记
- 转:基于Socket的UDP和TCP编程介绍
- SDL解析——SDL事件处理(1)