【问题标题】:View Contents of COM DLL in .NET application在 .NET 应用程序中查看 COM DLL 的内容
【发布时间】:2017-01-10 13:21:30
【问题描述】:

我是C# 的新手,需要在我的应用程序中使用COM DLL

我已经针对原来的DLL 执行了tlbimp,用regsvr32 注册了我的新DLL,用ildasm 查看了DLL 的内容,然后使用@ 重新创建并签署了DLL 987654330@(使用与我的 C# 项目相同的密钥)。 然后我将新签名的DLL 添加到我的GAC

我在我的应用程序中向DLL 添加了一个reference,并且能够在DLL 结构中输出每个methodType

我希望这个DLL 有一个array(s) 的值,但无法执行get 方法并且在结构转储文件中看不到任何数组。

我期望的两个数组类型为INTSTRING。这个DLL 应该能够填充combobox

下面是使用ildasm的DLL转储

有人可以告诉我这个DLL 中是否确实有一组值,或者我是否应该停止旋转我的轮子?

___[MOD] 
   |      M A N I F E S T
   |___[NSP] CSCICom_Usable
   |   |___[INT] CSCICom_Usable.Class1
   |   |   |     .class interface public abstract auto ansi import 
   |   |   |      implements CSCICom_Usable._Class1 
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 32 34 42 33 31 37 34 37 2D 41 46 42 36   // ..$24B31747-AFB6 ...
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.CoClassAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 1A 43 53 43 49 43 6F 6D 5F 55 73 61 62 6C   // ...CSCICom_Usabl ...
   |   |
   |   |___[CLS] CSCICom_Usable.Class1Class
   |   |   |     .class public auto ansi import 
   |   |   |      implements CSCICom_Usable._Class1 
   |   |   |      implements CSCICom_Usable.Class1 
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.TypeLibTypeAttribute::.ctor(valuetype [mscorlib]System.Runtime.InteropServices.TypeLibTypeFlags) = ( 01 00 02 00 00 00 00 00 )  ...
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 37 32 43 45 36 35 44 45 2D 46 30 42 38   // ..$72CE65DE-F0B8 ...
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.ClassInterfaceAttribute::.ctor(valuetype [mscorlib]System.Runtime.InteropServices.ClassInterfaceType) = ( 01 00 00 00 00 00 00 00 )  ...
   |   |   |___[MET] .ctor : void()
   |   |   |___[MET] GetIncidentCodes : class [VBA]VBA.Collection()
   |   |
   |   |___[INT] CSCICom_Usable.Class2
   |   |   |     .class interface public abstract auto ansi import 
   |   |   |      implements CSCICom_Usable._Class2 
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 41 38 38 36 33 32 42 42 2D 41 46 46 31   // ..$A88632BB-AFF1 ...
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.CoClassAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 1A 43 53 43 49 43 6F 6D 5F 55 73 61 62 6C   // ...CSCICom_Usabl ...
   |   |
   |   |___[CLS] CSCICom_Usable.Class2Class
   |   |   |     .class public auto ansi import 
   |   |   |      implements CSCICom_Usable._Class2 
   |   |   |      implements CSCICom_Usable.Class2 
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.TypeLibTypeAttribute::.ctor(valuetype [mscorlib]System.Runtime.InteropServices.TypeLibTypeFlags) = ( 01 00 02 00 00 00 00 00 )  ...
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 41 30 43 39 46 42 45 45 2D 42 36 45 38   // ..$A0C9FBEE-B6E8 ...
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.ClassInterfaceAttribute::.ctor(valuetype [mscorlib]System.Runtime.InteropServices.ClassInterfaceType) = ( 01 00 00 00 00 00 00 00 )  ...
   |   |   |___[MET] .ctor : void()
   |   |   |___[MET] get_Code : int16()
   |   |   |___[MET] get_Name : string()
   |   |   |___[MET] set_Code : void(int16)
   |   |   |___[MET] set_Name : void(string)
   |   |   |___[PTY] Code : int16()
   |   |   |___[PTY] Name : string()
   |   |
   |   |___[INT] CSCICom_Usable._Class1
   |   |   |     .class interface public abstract auto ansi import 
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.TypeLibTypeAttribute::.ctor(valuetype [mscorlib]System.Runtime.InteropServices.TypeLibTypeFlags) = ( 01 00 D0 10 00 00 00 00 )  ...
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 32 34 42 33 31 37 34 37 2D 41 46 42 36   // ..$24B31747-AFB6 ...
   |   |   |___[MET] GetIncidentCodes : class [VBA]VBA.Collection()
   |   |
   |   |___[INT] CSCICom_Usable._Class2
   |   |   |     .class interface public abstract auto ansi import 
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.TypeLibTypeAttribute::.ctor(valuetype [mscorlib]System.Runtime.InteropServices.TypeLibTypeFlags) = ( 01 00 D0 10 00 00 00 00 )  ...
   |   |   |     .custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 41 38 38 36 33 32 42 42 2D 41 46 46 31   // ..$A88632BB-AFF1 ...
   |   |   |___[MET] get_Code : int16()
   |   |   |___[MET] get_Name : string()
   |   |   |___[MET] set_Code : void(int16)
   |   |   |___[MET] set_Name : void(string)
   |   |   |___[PTY] Code : int16()
   |   |   |___[PTY] Name : string()
   |   |
   |

【问题讨论】:

  • 您在寻找什么样的值数组?值应该代表什么?
  • 我希望这个应用程序能够给我两个数组的值,一个是 STRING 另一个是 INT 另外我希望这两个值相互关联,它们是警察代码和代码名称
  • 如果您觉得这值得一票否决,请至少解释一下,以便我改进
  • 我怀疑 StackOverflow 上的某个人以相当随意的方式对标记为 comatlactivex 等的问题投了反对票。一个常见的模式似乎是低代表用户的问题,即新用户。

标签: c# .net dll com com-interop


【解决方案1】:

所以在继续实现我的 COM DLL 并同时替换我自己的方法之后。从那以后,我被告知并意识到了两件事

  1. 在上面的代码中,您可以看到 [MET] GetIncidentCodes 返回一个 VBA.Collection() 即一个数组。

  2. 有人告诉我集合中有两个项目。我真诚地希望它们不是 0 和空白.....但这就是我迄今为止能够返回的全部内容。

继续学习 C#

【讨论】:

    猜你喜欢
    • 2011-09-06
    • 2014-06-30
    • 1970-01-01
    • 2012-06-05
    • 1970-01-01
    • 2010-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多