Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 399123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:48:56+00:00 2026-05-12T16:48:56+00:00

I’m trying to call a custom action within my Setup & Deployment project to

  • 0

I’m trying to call a custom action within my Setup & Deployment project to update some items within the app.config on my app. I’ve wrapped up the custom config section in the usual way, e.g.:

[ConfigurationProperty("serviceProvider", IsRequired = true)]
public string ServiceProvider
{
    get { return (string)base["serviceProvider"]; }
    set { base["dataProviderFactory"] = value; }
}

I’ve set the custom action to be called during the Install section of installation just after base.Install(stateSaver). The code is:

string exePath = string.Format("{0} MyApp.exe", Context.Parameters["DP_TargetDir"]);
SysConfig.Configuration config = ConfigurationManager.OpenExeConfiguration(exePath);
Configuration. MyApp section = Configuration.MyApp)config.GetSection("MyApp");

When I run this, I get this error:

System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for MyApp: Could not load file or assembly ‘MyCompany. MyApp.Configuration’ or one of its dependencies. The system cannot find the file specified. (C:\Program Files\MyCompany\MyApp\MyApp.exe.config line 5) —> System.IO.FileNotFoundException: Could not load file or assembly ‘MyCompany.MyApp.Configuration’ or one of its dependencies. The system cannot find the file specified.

Line 5 in the config is:

<section name="MyApp"
    type="MyCompany.MyApp.Configuration.MyApp, MyCompany.MyApp.Configuration"
    requirePermission="false" />

The class library with the installer code (that being the only class in that library) has a reference to the config assembly.

Is there something really obvious that I’m missing here? I can’t work out why the ref to the config isn’t being found.

Any help/suggestions would be very much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:48:56+00:00Added an answer on May 12, 2026 at 4:48 pm

    I managed to find some code on MSDN that provides a working (albeit hacked) way to do this. Link is here: ConfigurationManager, custom config, and installutil / path searching problem.

    Wouldn’t have found it if not for being able to debug with help from suggestions so thanks to both of you for that.

    For reference, my final install code is:

    public override void Install(IDictionary stateSaver)
    {
        base.Install(stateSaver);
    
        string targetDirectory = Context.Parameters["DP_TargetDir"];
        stateSaver.Add("TargetDir", targetDirectory);
    
        string exePath = Path.Combine(targetDirectory, "MyApp.exe");
    
        System.Diagnostics.Debugger.Break();
    
        ResolveEventHandler tempResolveEventHandler =
            (sender, args) =>
                {
                    string simpleName = new AssemblyName(args.Name).Name;
                    string path = Path.Combine(targetDirectory, simpleName + ".dll");
                    return File.Exists(path)
                        ? Assembly.LoadFrom(path)
                        : null;
                };
    
        try
        {
            // hook up asm resolve handler  
            AppDomain.CurrentDomain.AssemblyResolve += tempResolveEventHandler;
    
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(exePath);
            Configuration.MyApp section = (Configuration.MyApp) config.Sections["MyApp"];
    
            if (section != null)
            {
                // "ApplicationSettings.DefaultDatabasePath" is the custom config value I'm updating
                section.ApplicationSettings.DefaultDatabasePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                config.Save();
            }
        }
        finally
        {
            // remove asm resolve handler.  
            AppDomain.CurrentDomain.AssemblyResolve -= tempResolveEventHandler;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 191k
  • Answers 191k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Maybe you can use On Error Resume Next, along with… May 12, 2026 at 6:13 pm
  • Editorial Team
    Editorial Team added an answer Use the subprocess module (Popen) and have the result written… May 12, 2026 at 6:13 pm
  • Editorial Team
    Editorial Team added an answer Your risks are no greater than web development in general.… May 12, 2026 at 6:13 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.