无法嵌入Interop类型

时间:2015-01-29 05:42:42

标签: c# visual-studio-2012 interop

我有来自外部供应商的dll;它包含2个类:

namespace RDTiffDataAccess
{
    public class RDTiffDataClass : IRDTiffData, RDTiffData
    {
        public RDTiffDataClass();
    }
}

namespace RDTiffDataAccess
{
    public interface IRDTiffData
    {
        // some code
    }
}

我尝试调用构造函数:

RDTiffDataAccess.IRDTiffData Rdt1 = new RDTiffDataAccess.RDTiffDataClass();

它给了我一个错误:

Interop type 'RDTiffDataAccess.RDTiffDataClass' cannot be embedded. Use the applicable interface instead.

我通过更改Embed Interop Types = false搜索并尝试了可能的解决方案。

现在它编译好了,但在运行时,会抛出异常:

Retrieving the COM class factory for component with CLSID failed 
due to the following error: 80040154 Class not registered 
(Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我知道这是一个老问题,但可以帮助其他人。 尝试在“构建”部分将项目属性更改为x86平台目标。 也许dll是针对86位构建的。