|
I'm not keen on this idea because you aren't testing like for like code (and yes, testing exception handling is testing the code). In other words, each environment is required to behave differently, which means that you cannot be 100% confident that your code will behave correctly as you haven't tested it in the previous environment.
|
|
|
|
|
Point taken! I was looking for more ideas from everyone else and assumed my idea was not the best approach. Can you provide some ideas about how you handle such? I am using Log4Net if that matters.
I am pretty sure I am not the first to come across this.
CodingYoshi
Artificial Intelligence is no match for Human Stupidity.
|
|
|
|
|
It really depends on what you are hooking into. If you are logging your errors into a database, then you could have a configuration in that database to identify the level of detail to provide, or you could have the actual error message in there. Supposing that the Guid that you display in QA is the identity of the logged error, then your message could be "There was an error logged with id {0}".
Now, if you provide the Guid into this using string.Format and there's no {0} written there then the Guid wouldn't be written out in the error message - satisfying that criteria of not displaying unecessary info to the end user.
|
|
|
|
|
CodingYoshi wrote: 1. I can read from config file for the phase and provide errors accordingly
2. I can have a preprocessor directive defined for each phase
I'd recommend a unified way of phoning home; have every unexpected exception be automatically logged in the bugtracker, and have the bugtracker look up the actual phase of development.
You could add in a conditional compile; adding some complexity that does not add much value to the end-product.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
You could think about using log4net - this will handle a lot of the logging framework for you.
If you want you can turn off debugging logs in the production environment.
|
|
|
|
|
I am using Log4net as I have mentioned. How can I turn off debugging log?
Please note one of the things I am trying to do is providing different error messages to users based on whether the product is in qa or production. In qa the user will be qa. In production it will be, obviously, a regular user.
CodingYoshi
Artificial Intelligence is no match for Human Stupidity.
|
|
|
|
|
Store your error messages in a database, and read them from there. I wouldn't recommend using resource files for this because it would mean that you have to do a different deploy between the environments.
|
|
|
|
|
Hi,
I am working on a project which involves controling the mediaelement to play videos from the server side. So far, I have no idea at all. I will be grateful if someone can give me a hint. I use visual studio C# as the development tool.
|
|
|
|
|
You need to look into streaming the video. As you haven't said what your client actually is, I can't be any more specific than that - but you now know that one of the keywords to search for in Google is "streaming".
|
|
|
|
|
Thanks so much. I really appreciate you answer.I have learnt something. As I am a newcomer to programming, I think I didn't make my question clear. Actually, I want to make two applications. The first one act as a server which can send a command via the Internet to the second one to request it to play a video. The second application is nothing more than a video player with embeded video files. My question is how do I write a programme which can send a command to the other application to request it to play a video.
|
|
|
|
|
If I were you, I'd look into using Windows Communication Foundation (WCF). This technology is designed to let you write code that can communicate using different transports (HTTP, TCP, etc), with the same code.
|
|
|
|
|
hi guys. i'm really need this .
i have a datagridview with 5 columns . i just attached my datagridview to my table in my access database what i want to do is to convert the first column from string to int , bcz it's saving as string in database and not as int .
the problem is when i hit the column header to sort the data grid viye by the first column is sorting like this .
11
1
2
55
6
7
8
but i want to sort it like this 1-2-6-7-8-11-55
.i think it bcz of the string format of the column do you know any way to convert the column . i think it should be fix if i convert the column from string to int or maybe it'll solve in other way .
|
|
|
|
|
I think (its been a while since I did winforms) you should probably change the underlying data collection. possibly do the conversion way back in the SQL query (assumption).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
im sorry , but dont you mean to changing the value type of the column in access database or do sth else ?
|
|
|
|
|
Could you please not use text speak in questions? It makes it very hard for those of us who don't use it to translate it into English.
What he's talking about is transforming the type in your query - not in the database, but why would you want to store an integer value in a string anyway? Is there a reason you are doing this?
|
|
|
|
|
You have a couple of choices, convert the data type in your select query or add another column either in your query or the data table resulting from the query and populate the new column with the integer value.
And as POH said don't use text speak when you are using a computer!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Can we have a parametrised constructor in a static class?
|
|
|
|
|
Basically no. Static classes cannot have public constructors (any access modifier i.e public or private, in fact), and static constructors cannot have parameters.
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
No. How would you call it? Static constructors are called by the framework at a time which your code can't know*, and without any parameters. In fact the same construct in Java makes this clearer by just being
static {
}
... so it doesn't look like a callable method (which it isn't).
(*: It's called the first time the class is fully loaded, which I think happens when a method/field/property is called. However, you still don't know when that is because some other code might use the same class.)
If you want to preload state then you can have a parameter-accepting normal static method which you call in the Main procedure or via a static constructor elsewhere. (Obviously, you could call it from anywhere, but you want to call it before you are going to use the class at all, and Main is about the only place you can guarantee that.)
|
|
|
|
|
No. Is that a homework question or is there a problem you're trying to solve? If the latter, what are you trying to solve?
|
|
|
|
|
We can have a constrictor in a static class (thought not a parameterized one).
Read more about this here[^].
|
|
|
|
|
Abhinav S wrote: We can have a constrictor in a static class
Does that narrow the scope of variables?
[Edit]Univote countered.
modified 11-Sep-12 14:12pm.
|
|
|
|
|
No. Think about it. You need to have the static initialized when an instance of a class is created.
|
|
|
|
|
i have a problem in my code for doing the slectedindex event.pls help
SqlCommand cmd = new SqlCommand("select firstname,phoneno from user1 where rollno='" + comboBox1.SelectedItem + "'", con);
SqlDataReader dr;
con.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
textBox1.Text = dr[0].ToString();
textBox2.Text = dr[1].ToString();
label4.Visible = true;
label4.Text = "show";
}
con.Close();
|
|
|
|
|
What error are you getting ?
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|