简体   繁体   English

未定义类型'集合'vb BC30002

[英]Type 'Collection' is not defined vb BC30002

I am attempting to migrate a legacy vb.net application to .net standard and turn it into a nuget package. 我正在尝试将旧版vb.net应用程序迁移到.net标准,并将其转换为nuget程序包。 A good amount of it has been straight forward. 其中很大一部分是直截了当的。 I am currently hung up on this error caused by functions like this. 我目前正在挂断由此类功能引起的此错误。

 Public Property ErrorMessages As Collection
        Get
            ErrorMessages = _errorMessages
        End Get
        Set(value As Collection)
            _errorMessages = value
        End Set
    End Property

If i import System.Collections.ObjectModelCollection(Of T) it is asking me for a type and i am unsure how to proceed. 如果我导入System.Collections.ObjectModelCollection(Of T),它正在问我一种类型,我不确定如何进行。 It turns my code into Collection(Of,) and expects a second argument. 它将我的代码转换为Collection(Of,)并需要第二个参数。 Has anyone faced this before? 有人遇到过吗? Do i use a different import statement or how is this dealt with in vb now? 我是否使用其他import语句,或者现在在vb中如何处理?

You should almost certainly replace Collection with Dictionary(Of TKey, TValue) , using the dictionary type from the System.Collections.Generic namespace. 您几乎应该使用System.Collections.Generic命名空间中的字典类型,用Dictionary(Of TKey, TValue)替换Collection

Once again, this requires you to fill in the genetic type arguments TKey and TValue with the actual types. 再一次,这要求您用实际类型填写遗传类型参数TKeyTValue You need to figure out from context which type fits the collection. 您需要从上下文中找出适合集合的类型。 The value of TKey is probably String since that's the only key type VB6' collections properly support. TKey的值可能是String因为这是VB6集合正确支持的唯一键类型。 And given the name ( ErrorMessages ), TValue is probably String as well. 并给定名称( ErrorMessages ), TValue也可能是String

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM