|
I've recently upgraded to Visual Studio 2008 (having used Visual Studio 2005) up until now and ran into a nasty bug which took me hours to sort out.
I've always had a config file (in XML format) which I used to store configuration settings for my apps. My convention has always been to name this file MyApplicationName.config . I've noticed that sometimes Visual Studio generates a file called MyApplicationName.exe.config but I hadn't bothered to figure out what this file is all about as it appeared to me that it wasn't always created and it didn't matter whether I include it with the release or not anyway.
Now it seems that Visual Studio 2008 uses my naming convention as opposed to adding the .exe bit in so all of a sudden my config file clashed with the one the CLR (or whoever) expected. The problem only manifested when I try to connect to a DB or a TCP port. I can easily change my naming convention so it's not a problem anymore but I thought now might be a good time to find out what this config file is all about.
Could someone point me to an article or description perhaps? I have some specific questions:
Why do I sometimes see this config file and at other times it is absent?
Could I not use the existing config file and add my config settings to it or is it best to have my own seperate config file?
|
|
|
|
|
Dewald wrote: Could someone point me to an article or description perhaps?
Sure, why not[^]
led mike
|
|
|
|
|
OK thanks. I guess I should have found it myself
It still doesn't answer my questions though. And also it does not match what I'm experiencing here. According to the article the config file will be named MyApp.exe.config and that is what used to be the case when I used VS2005 but now that I'm using VS2008 the name is MyApp.config which clashes with my own config file that I've always used.
Moreover, even if the file isn't present (and I still don't know when to expect to see the file and when not), a call to AppDomain.CurrentDomain.SetupInformation.ConfigurationFile reveals that the name is MyApp.config and not MyApp.exe.config . What gives?
I've seen that you can add an "Application Configuration File" to your project but I have not done this. Even so, if I have my own MyApp.config file in the application directory the program crashes when I try to access a DB or TCP socket. Other applications in which I don't access DB's or sockets couldn't care less whether there is a file called MyApp.config or not.
|
|
|
|
|
Dewald wrote: and I still don't know when to expect to see the file and when not
I have no idea what that means? "when to expect to see the file", see the file?
Dewald wrote: Even so, if I have my own MyApp.config file in the application directory the program crashes when I try to access a DB or TCP socket.
Dude, calm down, you just need to learn about config files. Don't think of them as some magic solution that you don't need to understand. Like everything else you do need to understand so take the time to learn. That article I linked to should be a place to start but there is certainly more information.[^]
led mike
|
|
|
|
|
led mike wrote: I have no idea what that means? "when to expect to see the file", see the file?
It means that I can make a call to AppDomain.CurrentDomain.SetupInformation.ConfigurationFile which gives me the name of a file, yet nowhere in the application directory does such a file exist. If the file existed I would have expected to "see the file".
led mike wrote: Dude, calm down, you just need to learn about config files. Don't think of them as some magic solution that you don't need to understand. Like everything else you do need to understand so take the time to learn. That article I linked to should be a place to start but there is certainly more information.
See, right here you've touched on what is probably the very essence of my frustration. I've been programming for close to two decades now so one would think that I'd know how to get to the bottom of new programming issues quickly. One would think that I'd know what there is to know about programming but I don't and I still get daunted by the plethora of information out there.
I made the switch to C# not too long ago and it was clear to me from the outset that it would take years to understand everything but I'm being paid to develop applications and don't have years to spend. So obviously I prioritise and get to understand the important things first. I didn't get the impression that configuration files were high on that list of important things. The fact that the book I purchased[^] (which in retrospect seems to be a pathetic book by the way) makes no mention of configuration files whatsoever may have reinforced this notion.
Then, when I run into an issue like this, I turn to the internet to see what I can learn. I started off googling for answers but when I didn't really get the answers to my questions I thought I'd turn to CodeProject. I would assume that the two links you provided should be very good for getting me underway but neither gives me any hint as to why in VS2008 I'm getting an AppName.config filename when in VS2005 I got AppName.exe.config . Every minute that I spend researching this issue is a minute that I could have spent testing other aspects of my application or writing new code and I feel guilty for spending so much of the time for which I'm being paid to develop. So what do I do? I change my proprietary file name to something that doesn't clash with AppName.config , thinking that I'll bother with getting to the bottom of that issue later (and probably never do) so I can get on with my work.
Maybe I'm just not a good developer then but seriously, how many developers are there who understand every last article in MSDN? Is that what you allude to if you say "Like everything else you do need to understand so take the time to learn". And how many other developers are there who, like me, don't have the time to exhaustively research a matter like this when they actually have a workaround for the time being and while the deadline is rushing down on them?
OK, enough venting from me Maybe I'd have done better by using this time to research configuration files or work at meeting the deadline but this has always been something that concerned me. Am I a bad developer if I don't understand everything?
|
|
|
|
|
Dewald wrote: Am I a bad developer if I don't understand everything?
Bad is a relative term. Would one be a better developer if they actually know and understand the technology they work with? Of course. Operating in the dark will almost always result in Technical Debt[^]. One mistakenly believes they are cheating time by finishing faster, it is a mere illusion, a fantasy.
Dewald wrote: while the deadline is rushing down on them?
Ah yes, the pragmatism card. "Oh dear, a deadline, what will I do!" Let's say that digging into one topic like this one, config files, could keep a person busy for 1 or 2 maybe 3 days. At the end of that time they might not know everything, but would no longer be working with "magic". They would posses a great deal more knowledge than none. I submit that if those 2 days jeopardize a deadline, then there are far bigger problems with that project than any single developer can solve.
I will close my thoughts with one last observation. There is a significant gap between knowing nothing about a subject and knowing everything. Does not the pragmatists path lay somewhere between the two extreems?
led mike
|
|
|
|
|
led mike wrote: I submit that if those 2 days jeopardize a deadline, then there are far bigger problems with that project than any single developer can solve.
Ha! I like this one. And I fully agree.
After typing up the previous post I gave it some more thought and discussed it with a co-worker during lunch. In future I will refuse to feel guilty for spending company time to research issues such as this. If 2 or 3 days are required for me to get to understand .config files (and I suspect it will more likely be a couple of hours, not days) then that is the amount of time that this project requires extra in order for me to finish it.
I'm not just programming so that I can finish projects, I'm also programming so that I can become better and finish future projects more elegantly, more efficiently and quicker. So it only makes sense that my employer should pay me for researching such issues with the same willingness that he is paying me to do actual developing.
As a matter of interest, I have spent some time today to get to understand .config files and the basics seems to be fairly straight forward. A possible shortcoming (and further studying might reveal this to be moot) is that settings are stored as key/value pairs while I have a need to group key/value pairs according to different sections.
In other words, I can have the following in my config file:
<add key="DatabaseHost" value="192.168.0.5" />
<add key="DatabaseName" value="MyDB" />
<add key="TCPHost" value="192.168.0.10" />
<add key="TCPPort" value="12345" />
but I'd rather have preferred if these could be split into two sections, one called "Database" and one called TCP, each containing the key/value pairs that only pertains to that particular section.
Also, I found a discussion on the MSDN forums[^] where someone else experienced exactly the problem that I experienced and ultimately did not really get an answer to his question. I'm starting to wonder if I'll just have to accept the fact that VS2008 has a different naming scheme than VS2005 despite what the documentation says.
|
|
|
|
|
Hi there
I plan to develop an application a Windows Mobile 6 platform. Now have a “data base” stored in a txt file 100KB.
My question is about what kind of data structure to use: an Array, List, Dictionary or something based on a sql server.
|
|
|
|
|
It really depends on what your application does and what information you want to store.
|
|
|
|
|
i will store pair of words(noun-adjective)
|
|
|
|
|
Use SQLServerCe file based database.
If you insist on a text file an indexed flat file will be the fastest.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
If you want efficiency, the Dictionary (which is based on a hash table) is the best choice. Databases are slow and a bit more complex.
|
|
|
|
|
Hi all. I'm having a slight problem. I'm trying to write a method for performing HTTP GET and POST requests. It all works fine, but the problem I'm having is that the request gets sent without the parameters I've passed. The server then responds, and only then are the parameters sent. In one particular case, I'm trying to replicate the request in my application that is sent by internet explorer. In internet explorer, the headers and parameters are sent as a single request.
I used a packet sniffer to see what was going on.
In my application, this is the first frame sent:
http://img511.imageshack.us/img511/921/appframe1ag8.jpg
This is the second frame sent:
http://img511.imageshack.us/img511/8359/appframe2zy4.jpg
In comparison, this is the single frame sent in internet explorer (note that the payload at the bottom is combined as part of the request, which is what I want to achieve):
http://img514.imageshack.us/img514/8342/ieframe1fr7.jpg
My code is as follows:
/// <summary> | /// Performs an HTTP request | /// </summary> | /// <param name="uri">Uniform resource identifier</param> | /// <param name="method">HTTP request method (GET/POST)</param> | /// <param name="parameters">HTTP POST request parameters (example: "name1=value1&name2=value2")</param> | /// <param name="referer">Referer HTTP header URI</param> | /// <returns>Returns the server's response</returns> | public string HTTP_Request(string uri, string method, string parameters, string referer) | { | // Create a WebRequest object | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | // Set request properties | request.Method = method; | request.ContentType = @"application/x-www-form-urlencoded"; | request.CookieContainer = cookies; | request.KeepAlive = true; | request.Referer = referer; | request.UserAgent = @"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Win64; x64; .NET CLR 2.0.50727; SLCC1; Media Center PC 5.0;" + | ".NET CLR 3.5.30729; .NET CLR 3.0.30618"; | request.Accept = @"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, " + | "application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, */*"; | // If the HTTP request method is POST, send parameters to the server | if (method == "POST") | { | byte[] buffer = Encoding.UTF8.GetBytes(parameters); | Stream dataStream = null; | try | { | // Set the content length of the request data being sent | request.ContentLength = buffer.Length; | // Retrieve Stream object for writing data | dataStream = request.GetRequestStream(); | // Send data | dataStream.Write(buffer, 0, buffer.Length); | } | catch (Exception) | { | MessageBox.Show("HTTP_Request Error:\n\nRequest error"); | } | finally | { | if (dataStream != null) | dataStream.Close(); | } | } | // Get the HTTP request response | HttpWebResponse response = null; | StreamReader reader = null; | try | { | // Retrieve HttpWebResponse object containing the server's response | response = (HttpWebResponse)request.GetResponse(); | // Retrieve StreamReader object for reading data | reader = new StreamReader(response.GetResponseStream()); | // Return the trimmed server response | return reader.ReadToEnd().Trim(); | } | catch (Exception) | { | MessageBox.Show("HTTP_Request Error:\n\nResponse error"); | } | finally | { | if (response != null) | response.Close(); | if (reader != null) | reader.Close(); | } | return null; | } |
|
|
|
|
|
IIRC you need a new line after the parameters.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
You can also look at the HttpWebRequest.SendChunked property.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Hello I am a C++ developer but I would like to see the doability of something :
indeed I saw that many thirdparty controls can be installed and added to VC.Net and they will appear
in the Toolbox so developers can just drag and drop them into the Forms editor.
In MFC this does not exist.
I also saw that it is possible using the "smart tag" to apply certain properties and see the effect in place, so it is not a simple image or static area.
I'd like to understand how is that possible.
I suppose to download the VS SDK to be able to do that thing, no ?
Is there something in action I can see it and learn from it ??
Thank you in advance.
"The Awaited Saviour", Mohammed Baqir Al Sadr
|
|
|
|
|
Hi,
thanks in advance for your answers.
I realized a windows service by c# where exceptions are managed.
This service run continously for more than 1 month on server machine with Windows Server 2003 (Service Pack 1). However the service crashed. When an exception arrive I log it in a text file, but in this case I didn't write anything.
In windows event viewer I found this error:
Tipo evento: Errore
Origine evento: .NET Runtime 2.0 Error Reporting
Categoria evento: Nessuno
ID evento: 1000
Data: 14/11/2008
Ora: 14.53.29
Utente: N/D
Computer: DATASERVERR2
Descrizione:
Faulting application srvcconnettore.exe, version 1.0.0.0, stamp 49007432, faulting module kernel32.dll, version 5.2.3790.2919, stamp 462648c6, debug? 0, fault address 0x00015e02.
Per ulteriori informazioni, consultare la Guida in linea e supporto tecnico all'indirizzo http://go.microsoft.com/fwlink/events.asp.
Dati:
0000: 41 00 70 00 70 00 6c 00 A.p.p.l.
0008: 69 00 63 00 61 00 74 00 i.c.a.t.
0010: 69 00 6f 00 6e 00 20 00 i.o.n. .
0018: 46 00 61 00 69 00 6c 00 F.a.i.l.
0020: 75 00 72 00 65 00 20 00 u.r.e. .
0028: 20 00 73 00 72 00 76 00 .s.r.v.
0030: 63 00 63 00 6f 00 6e 00 c.c.o.n.
0038: 6e 00 65 00 74 00 74 00 n.e.t.t.
0040: 6f 00 72 00 65 00 2e 00 o.r.e...
0048: 65 00 78 00 65 00 20 00 e.x.e. .
0050: 31 00 2e 00 30 00 2e 00 1...0...
0058: 30 00 2e 00 30 00 20 00 0...0. .
0060: 34 00 39 00 30 00 30 00 4.9.0.0.
0068: 37 00 34 00 33 00 32 00 7.4.3.2.
0070: 20 00 69 00 6e 00 20 00 .i.n. .
0078: 6b 00 65 00 72 00 6e 00 k.e.r.n.
0080: 65 00 6c 00 33 00 32 00 e.l.3.2.
0088: 2e 00 64 00 6c 00 6c 00 ..d.l.l.
0090: 20 00 35 00 2e 00 32 00 .5...2.
0098: 2e 00 33 00 37 00 39 00 ..3.7.9.
00a0: 30 00 2e 00 32 00 39 00 0...2.9.
00a8: 31 00 39 00 20 00 34 00 1.9. .4.
00b0: 36 00 32 00 36 00 34 00 6.2.6.4.
00b8: 38 00 63 00 36 00 20 00 8.c.6. .
00c0: 66 00 44 00 65 00 62 00 f.D.e.b.
00c8: 75 00 67 00 20 00 30 00 u.g. .0.
00d0: 20 00 61 00 74 00 20 00 .a.t. .
00d8: 6f 00 66 00 66 00 73 00 o.f.f.s.
00e0: 65 00 74 00 20 00 30 00 e.t. .0.
00e8: 30 00 30 00 31 00 35 00 0.0.1.5.
00f0: 65 00 30 00 32 00 0d 00 e.0.2...
00f8: 0a 00 ..
Could you give me a solution to this problem? Thank you!
|
|
|
|
|
Did you install any updates lately? To windows 2003 or any software around? I remember about sum of these issues with Symantec software.
Code? Yeah i love it fried together with a glass of wine.
|
|
|
|
|
Hi,
thanks for your answer. I didn't install any updates. Now I restarted my service and it's working correctly.
Have you any ideas?
|
|
|
|
|
I have developed a C# project which includes a text area and few other items
And I tried to play a background music using a thread.
The program works fine in my home machine,.
But once i tried to run it on different machine, an error occurs,.
So I copied the entire project and I tried to run it on another machine.(That machine had Visual Studio 2005),
And it gave and an error and said that the music file is not accessible.....
But it was there...
Is there a reason for this.
And I've heard that there is a method to include the files(media files, and pictures) into the project so that at the end(after compiling) you just need to carry the .exe, Not .exe file and the other files in its folder.
This would be a great help if any one can help ,me!!!
|
|
|
|
|
Hi,
you could try to add the music file as "Embedded resource" into your project. Than it will be "placed" inside the .exe-file. But accessing the file is different from accessing it as a file on a disk. You have to use something like:
<br />
Stream ioStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MyNamespace.MySoundfile.wav");<br />
Have a look here http://support.microsoft.com/kb/319292[^]
Hope this helps.
Regards Sebastian
|
|
|
|
|
Thank You very much Sebastian!!!
Thanks for the reply you have given,......
But I still have a small problem, To play the music I have used the
quartz.dll as a reference,
If so how am I gonna use this RESOURCE syntax...
|
|
|
|
|
Hmm, depends on the default namespace of your application.
It should look like:
"MyDefaultNamespace.quartz.dll"
To get the default namespace, open the project settings and navigate to the Application tab.
|
|
|
|
|
i have the following code - what it should do is to retrieve the rows that have the same id but the content within the other columns are not the same.
sqlquery = "select * from " + Table2 + " where " + txt_comkey_tbl2.Text + " in (select " + txt_comkey_tbl1.Text + " from " + Table1 + ")";
dbCmd = new OleDbCommand();
dbCmd.Connection = dbConn;
dbCmd.CommandText = sqlquery;
dbCmd.CommandType = CommandType.Text;
db1Reader = dbCmd.ExecuteReader();
dp = new DataSet();
db1table = dp.Tables.Add(sqlquery);
for (j = 0; j < dbReader.FieldCount; j++)
db1table.Columns.Add(db1Reader.GetName(j), db1Reader.GetFieldType(j));
foreach (DataRow dr in db1table.Rows)
{
for (int i = 0; i < db1table.Rows.Count; i++)
{
if (dr["Name"].ToString() == db1table.Rows[i]["Name"].ToString())
{
if (dr["Value"].ToString() != db1table.Rows[i]["Value"].ToString())
{
// select the row from the database and display in the grid...
}
}
}
}
however when i run the code i don't get any values on the datarow but execute the same sqlquery in the database two rows are returned. is there perharps something that is not done correctly?????
|
|
|
|
|
Hi Melanie,
is the sqlquery-text correct (I mean are the values you are using correct).
Next question I have i, why aren't you using the db1Reader like this:
<br />
while(db1Reader.Read()) {<br />
<br />
}<br />
I don't see the point where you putting the Values from the db1Reader into the db1table. So I assume that db1table has no rows...
Hope this helps.
Regards
Sebastian
|
|
|
|
|