开发者

How to export constant strings from .Net to COM?

开发者 https://www.devze.com 2023-01-14 21:57 出处:网络
I have a .NET DLL which I call from a VB6 project. Until now, I\'ve had a public static class with a bunch of

I have a .NET DLL which I call from a VB6 project.

Until now, I've had a public static class with a bunch of

public const String STRING_NAME = "STRING VALUE";

When I needed to use one of them from VB6, I directly wrote inline the literal value in the code.

Now I'd like to replace those literals with the .NET constants.

I have tried changing the "const" for "static readonly", and I have added the GUID and ComVisible attributes, to the class, and now I can see the class in VB6, but it has no members.

I开发者_如何学Cs this possible at all? How?


COM doesn't have a mechanism for sharing constants (except for enumerations, but that won't help with strings).

Best bet might be do define a class which contains a set of get only properties to return the values, and then create an instance in the VB code (and keep around).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号