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 6796663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:30:55+00:00 2026-05-26T18:30:55+00:00

I am instantiating a .NET COM object and would like to update the ConfigurationManager.AppSettings

  • 0

I am instantiating a .NET COM object and would like to update the ConfigurationManager.AppSettings and ConfigurationManager.ConnectionStrings properties.
I have noticed that even though I have settings in the assembly config file, e.g. “ComLib.dll.config” those settings are not available at runtime.

I make a call to create the COM Object from an ASP Classic Web Page using the following:

Dim COMObject
Set COMObject = Server.CreateObject("COMAPI.COMObject")

I use my VS2010 debugger to step into the Constructor of my .NET COM Object (COMAPI.COMObject). This is the point were I inspect the ConfigurationManager to check what is loaded.

Both “Assembly.GetExecutingAssembly” and “Assembly.GetCallingAssembly” have the same result which is the full path to the “ComLib.dll” assembly registered location. Which is what I expect. This location also has the “ComLib.dll.config” file, which is not pulling through into the ConfigurationManager.

When I try to clear the AppSettings using the following command an exception occurs:

ConfigurationManager.AppSettings.Clear();

The exception is: “Server object: 006~ASP 0177~Server.CreateObject Failed~80131902”

My thoughts are that the above exception is the ASP Classic interpretation of “AppSettings is read-only” but I am not 100% sure.

What I move onto, is loading the “ComLib.dll.config” file and then running over each of the AppSettings items adding them to the ConfigurationManager.AppSettings set but that causes an exception as well: “Server object: 006~ASP 0177~Server.CreateObject Failed~80131902”.

The code I use in the .NET COM Object is as follows:

Assembly comApiAssembly = Assembly.GetExecutingAssembly();
string comApiLocation = comApiAssembly.Location;
configuration = null;
configuration = ConfigurationManager.OpenExeConfiguration(comApiLocation);
var toLoadEnumberable = configuration.AppSettings.Settings.GetEnumerator();
while (toLoadEnumberable.MoveNext())
{
    var current = (KeyValueConfigurationElement)toLoadEnumberable.Current;
    ConfigurationManager.AppSettings.Add(current.Key, current.Value);
}

I need my configuration information in the ConfigurationManager as this .NET COM LIB is used to make calls to other .NET Assemblies. The other .NET assemblies require configuration.

Thank you in advance.

  • 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-26T18:30:55+00:00Added an answer on May 26, 2026 at 6:30 pm

    I was able to get some help from the MSDN forums.

    Basically instead of using .Clear/.Add/.Remove on the ConfigurationManager.AppSettings I access a setting, if it exists or not, and set a value for that key:

    ConfigurationManager.AppSettings["Key"] = "KeyValue";
    

    This updates the ConfigurationManager.AppSettings. This is great because as I access parts of my application which are out of scope from the initial “ASP Classic” -> “COM API” call I am still able to get Application Settings from the ConfigurationManager.

    With all this said, I still don’t know how to edit the ConfigurationManager.ConnectionStrings.

    If I try .Clear / .Add / .Remove on ConnectionStrings an exception occurs. Any ideas on this issue?

    I will update this answer if I find more info.

    As an update: To get around the ConnectionString settings not having my settings, I have implemented the Unity Container IoC framework. I use a Static instance to host the IoC container and resolve my instances that way.

    By doing this I can register my Interfaces against Class Types at the COM API which means I can pass the Connection String Settings, via Constructor Injection, I want to the resolving instance as the Connection String Settings are in scope.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a classic ASP page that is instantiating a .Net object through a
I have a VB.net class registered for COM interop which I'm instantiating within an
I have a COM interop assembly, and I would like to check from a
I have a strange phenomenon while continuously instantiating a com-wrapper and then letting the
I have an ASP.NET MVC2 application that uses a parent controller to setup specific
I tried every trick in the book, creating a new object, instantiating it (even
I have many, (15-20) different XML files that I need to load to VB.Net.
I have a .NET module that I need to call from an instantiated class.
I have an application built in ASP.NET MVC 3 that uses SQL CE for
I have a class in VB.NET that has a method (called CurrentValue) that returns

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.