|
|
I'm making an application for a small sized business, it's coming along nicely. So far I've been using text documents and CSV files to store the data that they want. Nothing big, no need for an online database. My question now is this, with no 'formal' training in C# I have a couple of questions, firstly what is the purpose of app.config? Secondly, how would you store user settings of an application? I am currently testing around and tyring to explore the advantages of storing them in plain text file, or even in the registry.
What do you think?
P.S. Take it easy, if it's a dumb question apologies in advance.
|
|
|
|
|
The app.config is a damn handy thing, and unless you have some fairly bizarre requirements, you should make use of it. The only bad thing about the app.config is that assemblies (DLLs) cannot easily have their own app.config.
User settings (settings that can be changed by the user) are stored in a user config file in the appropriate special (hidden) folder (ProgramData in Vista). Google "c# settings" or something like that to get an idea of using them, or even search CodeProject articles. I know there are at least three articles here that deal with user settings.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: The app.config is a damn handy thing, and unless you have some fairly bizarre requirements, you should make use of it. The only bad thing about the app.config is that assemblies (DLLs) cannot easily have their own app.config.
User settings (settings that can be changed by the user) are stored in a user config file in the appropriate special (hidden) folder (ProgramData in Vista). Google "c# settings" or something like that to get an idea of using them, or even search CodeProject articles. I know there are at least three articles here that deal with user settings.
Thanks, I'm going to take a deeper look. I had no idea what it was for I figured it was an internal file or something produced by the compiler related to the build, not for execution.
|
|
|
|
|
EliottA wrote: how would you store user settings of an application?
I just use an XML file stored in the user's APPDATA directory.
|
|
|
|
|
Hi All
I have a calendar on one form and a schedule on the other form.
I have this code on the calendar
new Schedule().Show();
Every time i click on the calendar it opens a dialog box and if i keep clocking it will keep on open more dialogs.
I want it so that when i click on a date i will show me on the Schedule.
Can anyone help me?
Thanks in advance .
|
|
|
|
|
try using a singleton and then just update the form using methods you call from the first form
|
|
|
|
|
Well, your design is flawed. You should
0) make the Schedule form global
1) allocate it once in the constructor of the main form (making its default Visible state as false)
2) when you do whatever it is you do to cause the schedule form to be displayed, simply call schedule.Show().
3) Make the OK button on the schdeule form hide the form instead of closing it.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
from a curiosity pov is this similar to a singleton pattern or a modification on it?
|
|
|
|
|
My approach assumes that the schedule form will always be needed, and makes the allocation attempt only one time. Single allocation results in a performance gain (no overhead for the allocation, and the GC isn't needed), unless the schedule form constructor accepts some sort of parameter from the parent form. At that point, a property or helper function to be called before Show() would still prevent the need to constant reallocate.
I wouldn't use a singleton unless the boss told me to, or unless some other reason caused by the requirements or code forced me to do so.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I wouldn't use a singleton unless the boss told me to, or unless some other reason caused by the requirements or code forced me to do so.
Why not? I always thought it to be a useful pattern and seems to do similar to what you are saying. The only difference being that it initialises it on first use rather then at the beginning of the use of the form.
Is there a problem with it I should be aware of so I limit using it.
|
|
|
|
|
hopingToCode wrote: Is there a problem with it I should be aware of so I limit using it.
Not at all. I simply have a different way of doing it. Isn't programming fun?
BTW, my way of doing it enables me to simply call show when I want to see the dialog. I don't have to try allocating it first.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Different minds work in different ways and you can learn from all the different ways
What do you do about GC? what happens if your form has been GC while hidden or do you just put a check in place first?
|
|
|
|
|
It can't be GC'd until the parent form is disposed (because the schedule form is a member variable of the parent form), so the schedule form is always available once allocated.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I'm really confused with this issue.
I have an abstract form that derives from Form and has some buttons on it.
I have a private method in the base class that loops through the buttons and tests the visible property (i'm basically going to align all visible buttons evenly form the right). The thing is that all the buttons show as having their visible property as false, does anyone know why this would be?
<br />
btnCancel.Visible = true;<br />
Console.WriteLine(btnCancel.Visible);<br />
shows false
Is this something to do with the form being abstract?
Edit to Add:
I've just realised that when i exit from the method any buttons that were set within the method are showing correctly but the value is still wrong within the abstract class.
Cheers
Russell
|
|
|
|
|
Damn,
I was trying to change the values of the controls while the form was itself set to Visible = false
Doh!
Russell
|
|
|
|
|
Hello,
I am using WSE 3.0 to secure webservice with username and password. Username and password are stored in sql database. In order to use the database I derived a class from UsernameTokenManager to override AuthenticateToken method. However, the problem is that password in the database stores md5 hashes of the password. It means that the client should either:
1. send md5 hash of the password using PasswordOption.SendPlainText option
or
2. send plain text password using PasswordOption.SendHashed option but in this case the database should store password in plain text.
Is there any other option that I am missing? I would like to store passwords in database hashed so I guess the only possibility I have is option 1.
Thank you.
|
|
|
|
|
hi every body,
when we send email then come some auto reply messages.i am working on the email sending project.
i have a problem that how can i know, that particlur massege is auto reply massage.furthermore how many auto reply messages i have got,Number of open messages which i sended.
PLs help me for this problem.
thanks in advance
have a nice time
modified on Tuesday, October 28, 2008 6:55 AM
|
|
|
|
|
far too vague... for this you need to
either
a) Google
Or
b) buy a good book
|
|
|
|
|
OR
c) Learn English
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
It sounds like you need to be looking at the "In-reply-to" header of incoming messages, and comparing that to the "Message-id" of your outgoing mail. By matching the two and defining a time threshold between send and receive you should be able to detect auto-responders with reasonable accuracy.
It would fair to assume that anything that arrives back within 10-15 minutes of sending would be an auto-responder - well, either that or someone who's way too stressed out, or hopped up on stims
The only real foreseeable problem is going to be receiving mail servers that delay incoming messages for n minutes/hours (an anti-spamming technique) - if delayed enough it's going to be difficult to ascertain if it's an auto-response or a human response in code..
Google around for "email message headers" for a grounding.
modified on Tuesday, October 28, 2008 9:03 AM
|
|
|
|
|
I have a c# assembly, that will be passed to another developer to use as a dll. The other developer does not need to know the workings of the dll, so most of the classes are marked as internal. I have a few public classes that are exposed externally.
Now, i want to add some tests to the assembly (I know they should have been done first!!), but if i add another project to the solution, the test project cannot see the internal classes, so i cant write the tests. How do i get round this without making the classes public, which i dont want to do?
tia
Mark
ps, hope this is in the right forum, was not sure if it was here or vs
|
|
|
|
|
In .NET 2, you can mark assemblies as [assembly:InternalsVisibleTo("assemblyname...")], so you could use this to tell the assemblies to show internal assemblies to test application.
|
|
|
|
|
Thanks
I assume that if a developer that was using this dll, called there project "Tests" for example, they would see everthing as well. Not really a problem as I dont think they would call it Tests. Maybe I should call my test project something obscure
|
|
|
|
|
You can use the public key of your unit test assembly in there as well, so it becomes
[assembly: InternalsVisibleTo("mytestproject, PublicKey="32de3ba45e0a00a1")]
|
|
|
|