none
Is this a bug with Class Libraries? RRS feed

  • Question

  • I encountered an interesting issue. I have setup a Class Library. I have a parent class. In it, there are (in this order):

    1) 5 public static functions

    2) One public sub-class containing about 3 public static functions

    3) Another 4 public static functions

    Now when I compile the DLL and try to reference it in another project, the static functions from part 3) are not visible. Maybe I missed some doco somewhere but that makes absolutely no sense to me. If I rearrange the functions and make it so the public static  functions are all together before the sub-class then those functions are visible.

    Can anyone confirm that this is a problem or if there is a restriction in the way those functions have to be ordered?

    Cheers,
    SC
    Wednesday, February 25, 2009 10:59 PM

All replies

  • What does "not visible" mean?  Doesn't show up in IntelliSense, doesn't show up in Object Browser, compiler barfs when trying to call them.  Occam's razor says it's a misplaced closing brace.
    Hans Passant.
    Wednesday, February 25, 2009 11:08 PM
    Moderator
  • nobugz said:

    What does "not visible" mean?  Doesn't show up in IntelliSense, doesn't show up in Object Browser, compiler barfs when trying to call them.  Occam's razor says it's a misplaced closing brace.


    Hans Passant.


    Not visible means I couldn't call the function. Which was odd because the functions were perfectly callable when I directly added the exact same (i.e. 100% unchanged) source file (.cs) to the project previously. So no it didn't show up in Intellisense, didn't show in Object Browser. I'd open the reference and those functions that were after the sub-class in the source code didn't appear there at all. All I did was literally:

    1) Remove the .cs file from the main project

    2) Create a class library with the .cs file

    3) Compile to a DLL and add a reference

    Bingo... suddenly half the functions (those after the sub-class) were inaccessible. It just didn't know they existed.
    • Edited by SamCPP Wednesday, February 25, 2009 11:19 PM Added extra explanation
    Wednesday, February 25, 2009 11:16 PM
  • nobugz said:

    Occam's razor says it's a misplaced closing brace.

    I just diffed my code (SVN) and checked the braces. They all matched up fine in both the original (the one that had the problem) and the altered version (the now-working version). I'm pedantic about my indenting (Pascal/C programming background) - I use "Allman Style" indentation (ref: Style guide), so I'm 99.99% sure it isn't closing brace position.

    EDIT: Occam's razor says to me if I have a .cs that worked when included vs the DLL that didn't work and the source was unaltered then whatever program that generated the DLL is the problem!

    SC
    • Edited by SamCPP Wednesday, February 25, 2009 11:57 PM DLL generation the problem?
    Wednesday, February 25, 2009 11:45 PM
  • Bizarre problems like this require a good repro.  Post one to a file sharing service, like skydrive.live.com
    Hans Passant.
    Thursday, February 26, 2009 1:08 AM
    Moderator
  • Sorry I have taken a little while to get back to you nobugz. Got bogged down fixing some other code!

    Well I have tried to reproduce the issue with the exact same source code and simply recompiling it resulted in the functions being visible. I have a copy of the DLL that was flawed. I can't for the life of me tell why recompiling it would solve the problem. I thought it would be deterministic.

    But anyway... maybe someone else will have this problem later on and see this post and think "So I wasn't imagining things".
    Monday, March 2, 2009 11:04 PM