Adam Christopher

I have a core library assembly that defines several enumerations. I also have a user control in a separate assembly; some of its methods require enumerations defined in the core library assembly as parameters. This user control is to be used in a VB6 application.

The problem I face is that I do not want to expose the core library to VB6 (I do have access to the source code, but it would be nice if I didn't have to register and reference several assemblies just to get access to enumerations). The only solution to this problem that I have come up with is to redefine those enumerations in the user control's assembly and cast where necessary (these enums are just integers afterall). This seems rather kludgy and will cause version issues is the enums ever change. About a year back I did the same thing with the geoCountry enum in MapPoint; I had to ommit some countries because the enums differ from MapPoint 2004-2006 and the app had to be compatible with both.

What I'm looking for is the C# equivalent of "typedef someEnum exposedEnum". I understand that C# does not have a typedef equivalent, but I want to know if there is any way to expose a type in one assembly with the definition in another.



Re: Visual C# Language Exposing Types Across Assemblies

Peter Ritchie

What's public is what's exposed in C#. You can use the using directive to create an alias similar to C/C++'s typedef; but that's not publicly available to other assemblies.




Re: Visual C# Language Exposing Types Across Assemblies

Adam Christopher

The "using" directive is almost what I'm looking for; the problem is that aliases are valid only in their declaring source files. All searches on the matter point to imposible, but it's okay since it was merely out of curiosity that I wanted to know. A redefinition of the enumerations is the most acceptable solution in my case. Lesson learned: method parameter types should only be types that are available within the enclosing assembly (unless absolutely necessary).