Visual C# Developer Center > Visual C# Forums > Visual C# General > Type exposing from "Inner" assemblies
Ask a questionAsk a question
 

AnswerType exposing from "Inner" assemblies

  • Saturday, November 07, 2009 1:10 PMeager2008 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Assume an Assembly called MyApplicationAssembly refers to MyLibraryAssembly.
    MyLibraryAssembly refers to MyRudimentaryLibraryAssembly.
    MyRudimentaryLibraryAssembly declares e.g. an enum.
    This enum must be available to MyApplicationAssembly, but I do not want to refer to MyRudimentaryLibraryAssembly directly from MyApplicationAssembly.

    Is there a way to expose the enum as if it is declared in MyLibraryAssembly without copying it into MyLibraryAssembly ?
    (Which would reduce maintenance problems etc.)

Answers

  • Monday, November 09, 2009 7:39 AMJi.ZhouMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello Eager,

    Thanks for using MSDN forums! This is Ji Zhou and I will be working on this issue with you.

    As far as I know, if you want to use the enum defined in MyRudimemtartyLibraryAssembly, you have to reference this assembly in the client application project. This is the behavior as a library assembly is supposed to act.

    Why do you not want to reference MyRudimentaryLibraryAssembly directly from the MyApplicationAssembly? If your design is MyApplicationAssembly should not see MyRudimentaryLibraryAssembly's definition, the shared enum should not be put in MyRudimentaryLibraryAssembly, but in a common shared library.

    Only one exception is that we can use Reflection to get the enums from the MyRudimentaryLibraryAssembly directly without reference it. See reflection sample here,
    http://www.codeproject.com/KB/cs/SetEnumWithReflection.aspx


    Hope this helps and have a nice day!

     

     

    Ji Zhou

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked As Answer byeager2008 Monday, November 09, 2009 7:47 AM
    •  

All Replies

  • Monday, November 09, 2009 7:39 AMJi.ZhouMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello Eager,

    Thanks for using MSDN forums! This is Ji Zhou and I will be working on this issue with you.

    As far as I know, if you want to use the enum defined in MyRudimemtartyLibraryAssembly, you have to reference this assembly in the client application project. This is the behavior as a library assembly is supposed to act.

    Why do you not want to reference MyRudimentaryLibraryAssembly directly from the MyApplicationAssembly? If your design is MyApplicationAssembly should not see MyRudimentaryLibraryAssembly's definition, the shared enum should not be put in MyRudimentaryLibraryAssembly, but in a common shared library.

    Only one exception is that we can use Reflection to get the enums from the MyRudimentaryLibraryAssembly directly without reference it. See reflection sample here,
    http://www.codeproject.com/KB/cs/SetEnumWithReflection.aspx


    Hope this helps and have a nice day!

     

     

    Ji Zhou

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked As Answer byeager2008 Monday, November 09, 2009 7:47 AM
    •  
  • Thursday, November 12, 2009 9:47 PMeager2008 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks.

    The reason why this would be nice is that the MyRudimemtartyLibraryAssembly is actually an RCW assembly imported from 3'rd part containing this enum.
    Therefore I cannot just choose to define the enum in a shared assembly.
    Anyway, it is not a big deal for me, just thought that this may be a more or less common need.