0

我有一个 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'.

问题可能出在哪里?
也许我必须参考一些东西?如果是这样……我该怎么办?

问候。

4

1 回答 1

0

当我跑

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

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

@hans-passant 评论在我脑海中点亮了一盏灯,我在再次运行 tlbimp 之前删除了这两个文件......它可以工作。

于 2014-06-10T07:05:13.047 回答