Enum's in different assemblies
-
Hi all, I have just moved some Enumerations from one assembly to a new one. However, the solution no-longer builds, as the enum's have suddenly become non CLS-Compliant. Moving them back to the old assembly fixes the problem! Is it really the case that you cannot use enum's from different assemblies? I have google'd for the problem, but the only things I could find said to explicity define the enum as type int, which I have done without success. Any ideas? Thanks in advance, Simon.
-
Hi all, I have just moved some Enumerations from one assembly to a new one. However, the solution no-longer builds, as the enum's have suddenly become non CLS-Compliant. Moving them back to the old assembly fixes the problem! Is it really the case that you cannot use enum's from different assemblies? I have google'd for the problem, but the only things I could find said to explicity define the enum as type int, which I have done without success. Any ideas? Thanks in advance, Simon.
Simon_uk wrote: Is it really the case that you cannot use enum's from different assemblies? I use enums from different assemblies all the time. In fact you probably do too when ever you use an enum from the Framework itself. Can you post the exact error message? It might help narrow the problem.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way! My Blog
-
Simon_uk wrote: Is it really the case that you cannot use enum's from different assemblies? I use enums from different assemblies all the time. In fact you probably do too when ever you use an enum from the Framework itself. Can you post the exact error message? It might help narrow the problem.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way! My Blog
Thanks for your response. Colin Angus Mackay wrote: I use enums from different assemblies all the time. In fact you probably do too when ever you use an enum from the Framework itself. Yes, I realise this, which is what makes it even stranger (to me anyway!). Ok, to recreate this problem create a new solution and add two new projects (I added a class library (proj1) and a windows control library(proj2)). I added a new file to proj1, which contained the following enum definition:
public enum MyEnum { Monday, Tuesday, Wednesday }
In UserControl1 in proj2, I added a new property of Type MyEnum. This builds successfully. I then added the line:[assembly: CLSCompliant(true)]
to the AssemblyInfo.cs file (and added using System;) Now re-building gives this error: "c:\Working\testenum\controls\UserControl1.cs(43): Type of 'controls.UserControl1.Day' is not CLS-compliant". Any clues? Thanks again for your help, Simon. -
Thanks for your response. Colin Angus Mackay wrote: I use enums from different assemblies all the time. In fact you probably do too when ever you use an enum from the Framework itself. Yes, I realise this, which is what makes it even stranger (to me anyway!). Ok, to recreate this problem create a new solution and add two new projects (I added a class library (proj1) and a windows control library(proj2)). I added a new file to proj1, which contained the following enum definition:
public enum MyEnum { Monday, Tuesday, Wednesday }
In UserControl1 in proj2, I added a new property of Type MyEnum. This builds successfully. I then added the line:[assembly: CLSCompliant(true)]
to the AssemblyInfo.cs file (and added using System;) Now re-building gives this error: "c:\Working\testenum\controls\UserControl1.cs(43): Type of 'controls.UserControl1.Day' is not CLS-compliant". Any clues? Thanks again for your help, Simon.Did you add the line:
[assembly: CLSCompliant(true)]
to both projects?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way! My Blog
-
Did you add the line:
[assembly: CLSCompliant(true)]
to both projects?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way! My Blog