VBobCat
Well-known member
My project has a "Dialog" Form.
Its purpose is to allow user to select none, some or all itens among the content of a default array.
This default array with all possible choices must be dynamically generated on runtime.
This gets done by function defined into the class of that class.
Whenever needed, a new instance of this form is explicitly instanced (i.e. "Dim MyDialogX as New DialogX : Dim DialogXresponse= DialogX.ShowDialog()"), and user's selection is stored in a new array, of same type of that default one, which contains as many items as user has selected.
All this goes ok.
Sometimes, however, I need to get that default array directly, and I would like to do this without instancing a new form, to avoid overhead froim its layout and field instancing.
To accomplish that, I made that function - which dynamically generates this array - a shared one, and refer it via its base class whenever it is needed (i.e. "Dim DefaultArray = DialogX.GetDefaultArray()")
Albeit it works, I've got since then an everlasting annoying warning, "Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated"
Well, DialogX is not an instance, it is Class's Type itself. I understand that Forms have default instances in VB.NET and this is the cause of this confusion. I've read about it and learned that this is an issue of compatibility with VB6. However, I find disturbing that Type itself and one of its instances are ambiguously referred by the same statement.
My question is, can I disable a Form's self-generating default instance in order to get rid of this warning?
Thank you very much.
Its purpose is to allow user to select none, some or all itens among the content of a default array.
This default array with all possible choices must be dynamically generated on runtime.
This gets done by function defined into the class of that class.
Whenever needed, a new instance of this form is explicitly instanced (i.e. "Dim MyDialogX as New DialogX : Dim DialogXresponse= DialogX.ShowDialog()"), and user's selection is stored in a new array, of same type of that default one, which contains as many items as user has selected.
All this goes ok.
Sometimes, however, I need to get that default array directly, and I would like to do this without instancing a new form, to avoid overhead froim its layout and field instancing.
To accomplish that, I made that function - which dynamically generates this array - a shared one, and refer it via its base class whenever it is needed (i.e. "Dim DefaultArray = DialogX.GetDefaultArray()")
Albeit it works, I've got since then an everlasting annoying warning, "Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated"
Well, DialogX is not an instance, it is Class's Type itself. I understand that Forms have default instances in VB.NET and this is the cause of this confusion. I've read about it and learned that this is an issue of compatibility with VB6. However, I find disturbing that Type itself and one of its instances are ambiguously referred by the same statement.
My question is, can I disable a Form's self-generating default instance in order to get rid of this warning?
Thank you very much.