0

I have few questions regarding .NET COM component.

Basically I'm developing a .NET COM server (.DLL) to support our legacy system,the idea is legacy system invoke COM Server method, .NET COM code intern call our Hosted WCF services.

Initially, I have developed a .NET COM component (.DLL) with basic functionality(i.e without calling WCF services), written a VB-Script to access COM methods, everything is working fine.

For WCF services, the configuration related information is stored in app.config, but i do not see the app.config file is loaded into the app-domain

1) how to load the app.config for .NET COM server

2) how to debug .NET COM component

Thanks in advance.

IT Fresher
  • 155
  • 8
  • Is it an out-of-process COM Server (an .exe) or an in-process COM Server (a .DLL)? – Simon Mourier May 01 '13 at 08:25
  • Look at my answer http://stackoverflow.com/a/4535028 for a way to load app.config for a COM server. – adrianm May 01 '13 at 19:16
  • As for debugging part of your question, you can, for debugging, put the Debugger.Break (http://stackoverflow.com/a/4733789/284111) call in your code and then when hit allow Visual Studio to attach to the process. – Andrew Savinykh May 02 '13 at 01:21

1 Answers1

4

For WCF services, the configuration related information is stored in app.config

That's the problem statement. It is not, it is stored in a foo.exe.config file. Where "foo.exe" was the name of your test program. But it is not any more. Now the .exe that runs your code is the script interpreter. To get your config back, you'd have to rename the .config file to wscript.exe.config and copy it to c:\windows\system32. Or c:\windows\syswow64, it depends. Or cscript.exe.config, it depends. You can use Task Manager to find out which EXE runs the script, use MsgBox if necessary to keep it running long enough.

This is of course brittle and not maintainable, especially when you are not the first programmer with this problem that got to that machine. You'll overwrite somebody else's .config file and break his code.

Ugly problem. You need to configure your WCF services in code instead of a .config file for a real fix.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536