[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

.net Object property failing in VB6 on value types

tpcmurray

4/26/2007 3:38:00 PM

I've written a new C# backend for a legacy VB6 solution, and for our
upcoming release we are continuing to use the legacy GUI. Thus, I've
opted to write wrapper classes to mimic the old interfaces in an
attempt to eliminate VB6 code rewiring.

One of the legacy classes was named Property with a default property
of 'Value' of type Variant:
Public Property Get Value() As Variant ...
Public Property Let Value(ByVal vNewValue As Variant) ...

The .net version of the property is as follows:
public Object Value {
get { return _field.GetObject(); }
set { _field.SetValue(value); }
}

In VB6, I have a reference to the generated typelib (auto generated
from VS.Net 2005), and the Value property shows up as type Variant in
both the object browser and the watch window, and I can successfully
fetch value types from the get code. So far so good. However, on the
following line:
someobject.Property("byname").Value = strSomeString

I get the error 'Object Required.' The line worked before so it isn't
a pure VB6 problem. The call doesn't reach my c# code, so I know it
isn't a problem there. That leaves the black box interop system.

I've read about the MarshalAs attribute, which might have helped, but
it can't be used on properties. It can be used on fields, but I can't
simply have a public Object Value, because I don't store the Value's
data in that wrapper class, as you can see above. It's just a proxy.

Whatever solution I come up with I'd like to avoid changing the VB6
code (there are 600,000 lines of code believe it or not).

Any have any ideas?