Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WwDotNetBridge
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01617874
Message ID:
01618303
Vues:
48
>I took a quick look and i can confirm that the code does not work with the inherited class - unless you add attributes to the class. The issue is class inheritance which is (again) not directly supported by COM. Unless you mark an object [ComVisible] .NET doesn't create an extra type in the dynamic COM export and so there's no type library info available to access the properties. Using GetProperty()/SetProperty() works because it doesn't use COM access from FoxPro, but rather goes indirectly at the properties.
>
>The other way to make this work is to ensure that [ComVisible] is set on the object you're calling. If you add:
>
>
>    [ComVisible(true)]
>    public class Address {}
>
>    [ComVisible(true)]
>    public class VerifiedAddress : Address {}
>
>
>then the inherited properties are visible directly and you can access properties on VerifiedAddress. This is why this worked with COM initially because you had the COM attributes at the top (this may also work just by have the ComClass attribute but not quite sure)
>
>Note that you can also specify [ComVisible] at the assembly level so all types are automatically marked ComVisible. In Properties.cs:
>
>[assembly:ComVisible(true)]
>
>will automatically make every class COM visible and this is a good idea if you create a custom assembly specifically for being called from FoxPro. I haven't run into this because when I create my own classes for interop I tend to set the global ComVisible flag. Also in .NET in general inheritance is not actually very much - composition is a much more popular pattern, so it's actually fairly rare to see inherited types.
>
>Anyway, this works fine for your own code but obviously for external objects this won't necessarily work. Then again with COM Interop you can't access any objects that aren't [ComVisible] in the first place :-)
>
>Sorry for the long message - just writing down what I found while testing this out. Point is though - you can most definitely do everything you can do with COM Interop with wwDotnetBridge. The only exception I know of that still requires COM registration is using COM events (as described in the white paper).
>

Interesting - that answers a question I never had time to dig into, since I've run into this before. Thanks.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform