TlbImp错误TI1036无法导入SAFEARRAY(浮点)

时间:2014-06-06 15:01:50

标签: c# c++ .net com-interop tlbimp

我有一个包含简单接口定义的idl:

library DecoToniCfgLib
{

  importlib("stdole32.tlb");

  //....code
  //....code

  [
    object,
    uuid(A6F30650-53F5-4688-829A-C084BA1C7DC0),
    dual,
    nonextensible,
    helpstring("DecoToniConfig Interface"),
    pointer_default(unique)
  ]
  interface IDecoToniConfig : IDispatch
  {
    [id(1), helpstring("Opens the Tones config and returns the params")]
    HRESULT OpenToneConfigWindow([out, retval] TCodecParams* pVal);
    [id(2), helpstring("Opens the Tones config and returns the params in an array form")]
    HRESULT OpenToneConfigWindowArray([out, retval] SAFEARRAY(float)* pVal);
    [id(3), helpstring("Opens the masks config window")]
    HRESULT OpenMaskConfigWindow([out, retval] SAFEARRAY(TMask)* pVal);
  }; 

}

我添加了一个返回SAFEARRAY(float)的方法,但是当我运行TlbImp为托管代码创建导入库时,我得到:

TlbImp : error TI1036 : Cannot find 'System.Single[] OpenToneConfigWindowArray()' 
in 'DecoToniCfgLib.IDecoToniConfig' when implementing 'DecoToniCfgLib.IDecoToniConfig' 
in 'interop.DecoToniConfigLib.DecoToniConfigClass' 
from 'interop.DecoToniConfigLib, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'.

哪里可能是问题?
也许我必须引用一些东西?如果是这样......我该怎么办?

问候。

1 个答案:

答案 0 :(得分:0)

当我跑步时

tlbimp.exe DecoToniConfigLib.dll /out:interop.DecoToniConfigLib.dll

它创建了两个文件:DecoToniCfgLib.dll(定义为IDL的库)和interop.DecoToniConfigLib.dll

@ hans-passant评论点亮了我脑海中的一盏灯,我再次运行tlbimp之前删除了这两个文件......它确实有效。