ReadOnly Property not visible in VB.NET 
Author Message
 ReadOnly Property not visible in VB.NET

I have a really strange problem. I have a dll that is written with Managed
C++ that has a readonly property. This is what the property looks like when
I look at the dll with ILDASM:

.method public newslot specialname virtual
        instance float64  get_PropertyA() cil managed

Now, this property is perfectly visible in C++ and C#. But, when I try to
use this property with VB.NET, I get the following error:
C:\Documents and Settings\asdf\My Documents\Visual Studio
Projects\MissingPropVB\Form1.vb(51): 'Namespace1.Obj1.Private Overridable
Property PropertyA() As Double' is not accessible in this context because it
is 'Private'.

I have other readonly properties that are visible in VB.NET. It's only this
one property that just does not want to show up. If anybody has seen
anything as strange as this before, please post a message.

Thanks,
MT



Tue, 28 Jun 2005 23:05:36 GMT  
 ReadOnly Property not visible in VB.NET

Quote:
>I have other readonly properties that are visible in VB.NET. It's only this
>one property that just does not want to show up. If anybody has seen
>anything as strange as this before, please post a message.

Do you have a private variable named something like "propertyA"?

Keep in mind that VB isn't case sensitive. When the compiler does
member lookup, it sometimes stops on the first match it finds (with a
case insensitive comparison). If it happens to be inaccessible, the
compiler unfortunately doesn't continue to look for a public
alternative.

Mattias

===

http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.



Tue, 28 Jun 2005 23:47:41 GMT  
 ReadOnly Property not visible in VB.NET

Quote:
> Do you have a private variable named something like "propertyA"?

> Keep in mind that VB isn't case sensitive. When the compiler does
> member lookup, it sometimes stops on the first match it finds (with a
> case insensitive comparison). If it happens to be inaccessible, the
> compiler unfortunately doesn't continue to look for a public
> alternative.

That's an interesting point - However, I don't have any variables in the
class itself - They are stored in a separate database. The property just
reads from and writes to a database.... I looked at the entire assembly and
the only references I found were releated to the property itself.

I don't know if I made it clear before, but, I do have a set_PropertyA
method that is visible within the assembly. So, the property has a public
read permission and a public private write permission. I don't know if this
is what is causing the problem....

MT



Wed, 29 Jun 2005 02:48:55 GMT  
 ReadOnly Property not visible in VB.NET

Quote:
>I don't know if I made it clear before, but, I do have a set_PropertyA
>method that is visible within the assembly. So, the property has a public
>read permission and a public private write permission. I don't know if this
>is what is causing the problem....

Ok, that's probably it then. Properties with mixed accessibility isn't
CLS compliant, and is another thing that the VB.NET compiler chokes
on.

Mattias

===

http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.



Wed, 29 Jun 2005 04:17:27 GMT  
 ReadOnly Property not visible in VB.NET
That's just great. I just realized that there are more properties that are
exhibiting the same exact behavior. Is there a workaround? I really cannot
expose the set method to anybody other than functions internal to the
assembly - that's just a requirement. It seems to work just fine under C#
and C++. Why can't I do this under VB?

MT


Quote:

> >I don't know if I made it clear before, but, I do have a set_PropertyA
> >method that is visible within the assembly. So, the property has a public
> >read permission and a public private write permission. I don't know if
this
> >is what is causing the problem....

> Ok, that's probably it then. Properties with mixed accessibility isn't
> CLS compliant, and is another thing that the VB.NET compiler chokes
> on.



Wed, 29 Jun 2005 05:27:55 GMT  
 ReadOnly Property not visible in VB.NET

I have found that C# chokes on properties with mixed permissions.  It's
strange that you're only having this problem with VB.NET.

I just use a standard method instead of a property-set method when I need it
to be externally read-only:

    public __gc class MyClass {
        public: __property int get_MyProp();
        public private: void SetMyProp(int value);
    };

-Sean


Quote:
> That's just great. I just realized that there are more properties that are
> exhibiting the same exact behavior. Is there a workaround? I really cannot
> expose the set method to anybody other than functions internal to the
> assembly - that's just a requirement. It seems to work just fine under C#
> and C++. Why can't I do this under VB?

> MT



> > >I don't know if I made it clear before, but, I do have a set_PropertyA
> > >method that is visible within the assembly. So, the property has a
public
> > >read permission and a public private write permission. I don't know if
> this
> > >is what is causing the problem....

> > Ok, that's probably it then. Properties with mixed accessibility isn't
> > CLS compliant, and is another thing that the VB.NET compiler chokes
> > on.



Wed, 29 Jun 2005 08:41:16 GMT  
 ReadOnly Property not visible in VB.NET

Quote:


>I have found that C# chokes on properties with mixed permissions.  It's
>strange that you're only having this problem with VB.NET.



>> That's just great. I just realized that there are more properties that
are
>> exhibiting the same exact behavior. Is there a workaround? I really
cannot
>> expose the set method to anybody other than functions internal to the
>> assembly - that's just a requirement. It seems to work just fine under C#
>> and C++. Why can't I do this under VB?

It should not work on VB or C# since CLS compliance states that:
The accessibility of the property and of its accessors must be identical.

--
Steven Toscano, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.



Mon, 25 Jul 2005 03:44:15 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Help needed badly - In making a property Uneditable or readonly in vb properties window

2. How to make Methods and Properties visible to VB

3. Can toggle between visible and not visible.

4. VB's mousepointer property not working when set from event of custom ATL control

5. Property Page not Showing in VB

6. VB property page not updated due to event freeze

7. property sheet like VB, not VC

8. OCX properties not working in VB&VC++

9. Why not VB.NET?

10. Works in C# but not VB.NET???

11. Receiving events from VB.Net into C# not working

12. Toggle READONLY property on CEdit()?

 

 
Powered by phpBB® Forum Software