locked
VS Add-in with Custom Configuration Section RRS feed

  • Question

  • I've been banging my head on this one for 3 days now:

     

    I finally took the time to get a basic example working.

     

    Getting a Custom Configuration Section usable in a VSAddin:

     


    Instead of giving you all my code that isn't pertaining to the issue, I wrote up a simple sample.
    And instead of using my own, I found this:
        //http://msdn.microsoft.com/en-us/library/2tw134k3.aspx
        //How to: Create Custom Configuration Sections Using ConfigurationSection

    and used that code straight from msdn.

    ==============

    This code (which works fine at the msdn url above) does not work:

    private static string hardCodedSectionGroupName = "pageAppearanceGroup";
    private static string hardCodedSectionName = "pageAppearance";

    public static PageAppearanceSection RetrievePageAppearanceSection()
    {
               PageAppearanceSection config = (PageAppearanceSection)System.Configuration.ConfigurationManager.GetSection(hardCodedSectionGroupName + "/" + hardCodedSectionName);
        return config;
    }

     

    =========

     

    NOW THE ISSUE IN DETAIL:
    When I put that msdn code into a VSAddin project, it would not read the configuration data.


    The crazy thing is that I can read basic AppSettings/(Key/Value pair) just fine.

    I cannot for the life of me figure out what the deal is with the custom ConfigurationSection (PageAppearanceSection in this case).

    I get the same error over and over.

    "An error occurred creating the configuration section handler for
    pageAppearanceGroup/pageAppearance:
    Could not load file or assembly 'Project1' or one of its dependencies.
    The system cannot find the file specified.


    So I wrote another method, just to test out the error above.
    private static void ShowThatTheAssemblyandTypesExists()
    And it knows about "Project1"(.dll) just fine and dandy.

    ==============

    The conflicting issue is:
    ShowThatTheAssemblyandTypesExists() works just fine.
    -
    I then catch 2 exceptions (with very unique names)
    catch (Exception are_You_Serious_QuestionMark_Ex1)
    catch (Exception are_You_Serious_QuestionMark_Ex2)

    which both exceptions say the same thing "I don't know anything about Project1(.dll)".

    :<


    ==============


    One method knows all about Project1(.dll), and a few lines later, it says "I don't know anything about Project1(.dll).


    ................



    You may have to alter the location and path-reference (inside of the contents of the file) VSReadingBasicConfigAddin - For Testing.AddIn  (<<this file is in a zip that is inside the primary zip file.)

    The starting place to put a breakpoint would be:
    public static PageAppearanceSection RetrievePageAppearanceSection()


    If you want it to work (out of the box), then unzip to this directory:
    C:\work2\DotNet\src\v20Base\v35\ThirdParty\GranadaCoder\
    But you can unzip it anywhere of course......
    (and also put that "VSReadingBasicConfigAddin - For Testing.Addin" in the correct place)

    If you don't unzip it to the above location, you'll have to edit a path in the file:

    VSReadingBasicConfigAddin - For Testing.AddIn

    HOW TO GET THE SOURCE CODE:

    http://sharesend.com/qlmg0

    Go to the above URL, and you can download it.  Its a zip file.
    Note, I think there is a 90 day limit, so if you don't find it, its probably way too old.



    • Edited by LoudRock Friday, March 26, 2010 7:50 PM misspelling
    Friday, March 26, 2010 7:47 PM

All replies

  • Thanks for your sharing, this would help the people who met the same problem.

    Only one thing, when I try to take a look at it, the download URL is complaining "different ip". :(

    Sincerely,
    Wesley


    Please mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, March 29, 2010 6:33 AM
  • I was able to download the code from home (where I had posted the code from work), and had a colleague (not at my work) download it as well.

    You might try an alternate browser.

     

    You can also try this "slightly more direct" URL:

    http://sharesend.com/download/qlmg0

     

    ===========================

     

    ALSO, I've also posted the source code in an alternate way.

    You can get a copy of the zip using the svn command line

     

    c:
    cd c:\
    mkdir tempVSAddinIssue
    cd tempVSAddinIssue

    svn.exe export http://granadacodersvn.svn.beanstalkapp.com/dotnet/misc/VSAddinReadingBasicConfig.zip VSAddinReadingBasicConfig.zip --username granadacodersvnReadOnly --no-auth-cache --force

     

    The password (when you are prompted) is:

    readonly###

     

    (If you don't have a SVN source-control client command line tool, you can get one at:

    http://www.open.collab.net/servlets/OCNDirector?id=CSVN1.6.9WINS
    or
    http://www.open.collab.net/downloads/subversion/thankyou.html?_=d

    )

     

    (Please note that if you are reading this in the future (say anything past (Summer 2010)..... and the command line svn.exe call does not work, then assume I am no longer using beanstalk)

     

     

    • Edited by LoudRock Monday, March 29, 2010 1:13 PM misspelling
    Monday, March 29, 2010 1:09 PM
  •  

    At this point, if anyone could just retrieve the code, run it, and go "yeah, that's weird", that would be a big help......just a sanity check.

    Monday, March 29, 2010 1:33 PM
  • No 'love' on this one I guess.  I guess I'm confused, because having a non-hacky custom configuration section handler in a VSAddin would seem to me to be a pretty common need. 

    Ok, I'm off to hack-up a AppSetting(s) based version. :<

    If anyone has any input, please let me know and that would still be appreciated ... so I can go back and re-factor it correctly.

     

    Thanks..

    Thursday, April 1, 2010 1:48 PM