Click here to Skip to main content
15,900,461 members
Home / Discussions / C#
   

C#

 
GeneralRe: actual Subversion Revision Pin
Martin#9-Jan-07 9:25
Martin#9-Jan-07 9:25 
QuestionData breakpoint Pin
Bekjong9-Jan-07 2:28
Bekjong9-Jan-07 2:28 
AnswerRe: Data breakpoint Pin
Eric Dahlvang9-Jan-07 3:26
Eric Dahlvang9-Jan-07 3:26 
GeneralRe: Data breakpoint Pin
Bekjong9-Jan-07 3:29
Bekjong9-Jan-07 3:29 
QuestionHow to access files in Unix server from windows machine through C# code Pin
gknath9-Jan-07 2:19
gknath9-Jan-07 2:19 
AnswerRe: How to access files in Unix server from windows machine through C# code Pin
Luc Pattyn9-Jan-07 4:43
sitebuilderLuc Pattyn9-Jan-07 4:43 
QuestionDatagrid Issue Pin
Dragoh2119-Jan-07 0:48
Dragoh2119-Jan-07 0:48 
QuestionCOM objects in C# with config files. Pin
Marcus_29-Jan-07 0:46
Marcus_29-Jan-07 0:46 
Hello

I have a question about working with COM objetcs made in C#. Creating the objetcs is not a problem, my question is how to work with config files. How do I get information from an config file so that I can read it with my COM object?

My situation right now is that I have a .Net object that most of the time will be accessed by a .Net application, but somtimes by an application written in VB6 (or any language supporting COM). In the config file for the .Net application I have some parameters that I want to read, not just in the appSettings section but also for example configSections and system.diagnoostics section.

I hope that Microsoft has thought of that when they made .Net support COM, but I dont know how they did it if they did it. Antoher solution is to always try to read the config file with ConfigurationManager.OpenExeConfiguration(FilePath) but then I cant read some sections properly without resorting to converting them into a XMLDocument:

<code
  System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(FilePath);
  ConfigurationSection confsec = config.Sections["system.diagnostics"];

  System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
  doc.LoadXml(confsec.SectionInformation.GetRawXml());
  System.Xml.XmlNode node = doc.SelectSingleNode("system.diagnostics/switches/add[@name='Trace']");
  if (node != null)
  {
    System.Xml.XmlAttributeCollection attribs = node.Attributes;
    TraceSwitch generalSwitch = new TraceSwitch("Trace", "Controls the Trace Level");
    generalSwitch.Level = (TraceLevel)Convert.ToInt32(attribs.GetNamedItem("value").InnerText);
  }
</code>


Or should I abandon config files and use INI files instead?

Is there a way in an .Net object to see if the object is started by an application using COM or if it is an .Net application?

I hope the question(s) are reasonably clear and that someone could enlighten me in the way of using config files when the calling application is an COM application written in VB6.


Sorry for my bad english.

Best regards
/Marcus
Questionreturning values Pin
satyam1439-Jan-07 0:34
satyam1439-Jan-07 0:34 
AnswerRe: returning values Pin
Mircea Puiu9-Jan-07 0:36
Mircea Puiu9-Jan-07 0:36 
AnswerRe: returning values Pin
Colin Angus Mackay9-Jan-07 0:42
Colin Angus Mackay9-Jan-07 0:42 
AnswerRe: returning values Pin
M. A. Deniz Yalman9-Jan-07 0:45
M. A. Deniz Yalman9-Jan-07 0:45 
GeneralRe: returning values Pin
Colin Angus Mackay9-Jan-07 5:43
Colin Angus Mackay9-Jan-07 5:43 
AnswerRe: returning values Pin
ednrgc9-Jan-07 2:59
ednrgc9-Jan-07 2:59 
AnswerRe: returning values Pin
andyharman9-Jan-07 6:58
professionalandyharman9-Jan-07 6:58 
GeneralRe: returning values Pin
PandaBear113-Nov-09 16:29
PandaBear113-Nov-09 16:29 
Questionreading xml file to listbox Pin
Yustme9-Jan-07 0:13
Yustme9-Jan-07 0:13 
AnswerRe: reading xml file to listbox Pin
Colin Angus Mackay9-Jan-07 0:28
Colin Angus Mackay9-Jan-07 0:28 
GeneralRe: reading xml file to listbox Pin
Yustme9-Jan-07 0:45
Yustme9-Jan-07 0:45 
GeneralRe: reading xml file to listbox Pin
Colin Angus Mackay9-Jan-07 2:02
Colin Angus Mackay9-Jan-07 2:02 
AnswerRe: reading xml file to listbox Pin
Stefan Troschuetz9-Jan-07 0:29
Stefan Troschuetz9-Jan-07 0:29 
GeneralRe: reading xml file to listbox Pin
Yustme9-Jan-07 0:59
Yustme9-Jan-07 0:59 
GeneralRe: reading xml file to listbox Pin
Stefan Troschuetz9-Jan-07 1:06
Stefan Troschuetz9-Jan-07 1:06 
GeneralRe: reading xml file to listbox Pin
Yustme9-Jan-07 1:26
Yustme9-Jan-07 1:26 
QuestionHow to provide the Search option Pin
Vishalagrawal19-Jan-07 0:12
Vishalagrawal19-Jan-07 0:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.