Problem using enums from a dotnet dll coded in c#

G

Gregory Pakosz

Hello

I coded a dotnet class library in c# : let's name it ClassLib

in this library, i have some enum types and methods using them

public enum SomeEnum : uint
{
item1,
item2,
item3,
item4
}

in VB.NET when i try to use my class library i cannot invoke

someMethod.doStuff(ClassLib.SomeEnum.item1)

=> error "Value of type 'Integer' cannot be converted to ClassLib.SomeEnum"

i tried to change the enum definition in the c# code removing the "uint"
underlying type definition then all worked fine one the vb.net side.

however, i want to keep this ': uint' underlying type statement for c# use.

how then can i make the code work under vb.net ???

thx for any help
gregory
 
J

Jay B. Harlow [MVP - Outlook]

Gregory,
VB.NET does not support uint! (yet).

If you want to define the enum in C# and make it usable in VB.NET you will
need to define the Enum as int. Period.

The biggest problem with making your Enum Uint is that Uint is not CLS
compliant, which means that .NET languages, such as VB.NET, do not need to
support Uint. Even with Whidbey uints are not going to be CLS compliant.

Whidbey (VB.NET 2004/2005) will support uints, so sometime next year you may
be free to define enums with uint.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top