Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Enum's in different assemblies

Enum's in different assemblies

Scheduled Pinned Locked Moved C#
helpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Simon_uk
    wrote on last edited by
    #1

    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.

    C 1 Reply Last reply
    0
    • S Simon_uk

      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.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • C Colin Angus Mackay

        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

        S Offline
        S Offline
        Simon_uk
        wrote on last edited by
        #3

        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.

        C 1 Reply Last reply
        0
        • S Simon_uk

          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.

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • C Colin Angus Mackay

            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

            S Offline
            S Offline
            Simon_uk
            wrote on last edited by
            #5

            No, I thought I had tried that, but obviously not because it now works!! Thanks very much for your help - most appreciated! Cheers.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups