Settings file

  • Thread starter Thread starter John J. Hughes II
  • Start date Start date
J

John J. Hughes II

I am creating a new windows service and will have a windows form for setting
the runtime settings. In the past I have used the registry for this but
since MS seems to think this is a bad thing I was attempting to use the
settings file in .NET but I am running into several problems.

1) It seems two or more application can't easily access the same
configuration files. This is primarily because they are located in the
application user directory. Does anybody know how to move the user.config
file to a more logical location or at least consistent location.

2) Adding to the first problem the user.config file is located in the user
directory whereas the service wants to use another. This means that the
user may not be able to access the directory that the service access if my
understanding of permissions is correct.

Does anyone have suggestion on how to work around this or should I just
still to the registry?

Regards,
John
 
I am creating a new windows service and will have a windows form for setting
the runtime settings. In the past I have used the registry for this but
since MS seems to think this is a bad thing I was attempting to use the
settings file in .NET but I am running into several problems.

You should look into Remoting. The windows service can host a remoted
object and the UI can talk to the windows service through remoting for
configuration.
 
Patrick,

Remoting is a major pain in the neck and more trouble then its worth.
Normally I use a IP connection to send XML packets back and forth.

I really would prefer to have the service configured before it started
rather then starting it and then configuring it.

Thanks,
John
 
I really would prefer to have the service configured before it started
rather then starting it and then configuring it.

Then I would use the registry. Despite what Microsoft says these days,
it's kind of what the registry has been designed for and I think it
would fit with what you're trying to do.
 
John J. Hughes II said:
I am creating a new windows service and will have a windows form for
setting the runtime settings. In the past I have used the registry for
this but since MS seems to think this is a bad thing I was attempting to
use the settings file in .NET but I am running into several problems.

1) It seems two or more application can't easily access the same
configuration files. This is primarily because they are located in the
application user directory. Does anybody know how to move the user.config
file to a more logical location or at least consistent location.

2) Adding to the first problem the user.config file is located in the user
directory whereas the service wants to use another. This means that the
user may not be able to access the directory that the service access if my
understanding of permissions is correct.

Does anyone have suggestion on how to work around this or should I just
still to the registry?

Your question has been around for a couple of days, so I'll offer this even
though I don't directly have an answer.

I could swear that I ran across an application-wide way to maintain
settings. I believe that it uses an "app.config" file, and that the file is
stored in a globally-accessible location.

I don't recall off the top of my head how this is done, and I don't have the
..NET docs handy so can't look it up for you. But I'm pretty sure what you
want can be done, and I don't think it's all that hard either.

Of course, the above only addresses the two issues you mentioned. A third
issue may exists, which is that .NET creates a directory specific to an
executable (assembly? manifest? I get a little lost with these new ways to
package up code :) ), as near as I can tell, and so getting your service to
access the same settings file as the configuration application may still be
an issue. I suspect that's solveable though.

I hope that's at least a little bit helpful. :)

Pete
 
Peter Duniho said:
Your question has been around for a couple of days, so I'll offer this
even though I don't directly have an answer.

I could swear that I ran across an application-wide way to maintain
settings. I believe that it uses an "app.config" file, and that the file
is stored in a globally-accessible location.

I don't recall off the top of my head how this is done, and I don't have
the .NET docs handy so can't look it up for you. But I'm pretty sure what
you want can be done, and I don't think it's all that hard either.

Of course, the above only addresses the two issues you mentioned. A third
issue may exists, which is that .NET creates a directory specific to an
executable (assembly? manifest? I get a little lost with these new ways
to package up code :) ), as near as I can tell, and so getting your
service to access the same settings file as the configuration application
may still be an issue. I suspect that's solveable though.

I hope that's at least a little bit helpful. :)

Pete

The problem with the app.config file is its read only, I have decided to
just keep using the registry since it seems the best option for what I am
trying to accomplish.

Regards,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top