【发布时间】:2018-05-11 20:44:03
【问题描述】:
我有一个 dll,它有一个函数,需要几个 Microsoft.VisualBasic.Collection 类型的变量。但我尝试在 C# 中将它们作为 An Arraylist 和 A List 传递,但无济于事。
Severity Code Description Project File Line Suppression State
Error CS1502 The best overloaded method match for
'Object.RptOptimizer.BuildReport(string, string, System.Guid,
Microsoft.VisualBasic.Collection, Microsoft.VisualBasic.Collection, string,
string, System.DateTime, System.DateTime, string, string, string, string,
string, int, bool, int, int, bool)' has some invalid arguments EPWeb4
C:\inetpub\wwwroot\EPWeb4\Forms\RptParamsOptimizer.aspx.cs 271 Active
Severity Code Description Project File Line Suppression State
Error CS0012 The type 'Collection' is defined in an assembly that is not
referenced. You must add a reference to assembly 'Microsoft.VisualBasic,
Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
【问题讨论】:
-
也许显示您尝试过的代码以及您正在调用的函数的方法签名?
-
也许你也可以给我们看一些代码?这将有助于了解更多
-
根据docs,它位于
Microsoft.VisualBasic.dll,所以请参阅How to add reference to Microsoft.VisualBasic.dll?。事实上,这可能是重复的。或者只是在 c# 中将其声明为IList。然后只需在 c# 中将其声明为Microsoft.VisualBasic.Collection。或者将其声明为IList,因为Collection实现了这个接口。 -
顺便说一句,您应该更喜欢使用类型化的泛型集合。见Benefits of Generics 和When would you not use Generic Collections?。