Where is my .net assembly reading its config since it was posted as COM?

Ok I created a .net assembly and it works fine from my asp.net site. Now I want to host it as COM so I can use it in the old asp website. This works, except that it won't read the application settings from the config file.

I think he should read it from the same folder where I registered my assembly with regasm and where the .dll is located. I tried to copy the config file into two additional files (in case it reads from a different named file other than "assembly-file-name" +. Config These two files - app.config and application.config - seem to be unreadable with none of them.

Where is my .net assembly reading its config since being posted as COM?

+2


source to share


3 answers


If by COM you mean a COM application, then you must put your configuration in a file called EXE. YourApp.Exe -> YourApp.exe.config



If by COM you mean COM + then take a look at http://blogs.msdn.com/heikkiri/archive/2005/11/10/491568.aspx

+1


source


Sombody correct me if I'm wrong, but I don't think the DLL is reading the config file at all. Even though you can technically create a config file for DLL projects (using project properties), I don't think you should set up a DLL like this, and I don't think the framework supports it.

There are now two ways:



  • Ask the caller to pass appropriate parameter values ​​to objects as parameters
  • Create a method that reads the settings themselves and calls the method after the object is created.

EDIT
To check, you have to specify a config file application-name.config.xml

as you would for a WebForms application. But as I said, I doubt it will work ...

0


source


Ok, I found a solution that makes me happy.

I ended up hosting a COM object in Component Services. On the package, I selected "Properties" and selected the "Activation" tab, there I entered the location of my configuration file in the "Application Root Directory". Now, to get it working, I had to rename my config file to application.config, and somehow I also had to create a new file in the same location as application.manifest, with the following data:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
</assembly>

      

This actually solves the problem of having a "dll" to read the config file - in fact, since the component services are the host (instead of the exe / website), it defines the location / configuration.

Woop - and thanks for the input guys - I didn't think about the Thorsten issue mentioned earlier.

0


source







All Articles