473,549 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Console App Deleting my config file - HELP!

I have a simple C# console app that needs to read the appname.exe.con fig
file to get db connect strings etc. from the <appSettings> . When the app
starts, it deletes the file! I can't figure it out. When I set a break point
on the first line in MAIN and check for the file, it is gone!

This is a 4 hour app, but I have spent all day trying to understand why the
config file is being deleted. Any help would be greatly appreciated.

Thanks very much in advance,

Richard Kessler
Jul 21 '05 #1
3 4295
Hello Richard,

Thanks for your post. As I understand, the proboem you are facing is that
your application configuration file will be deleted automatically. To
narrow down the problem, I think more information is needed:

1. Where does the config file reside? Did you add it to your project?

2. Does the problem occur to a specific project or to all the projects? I
recommend you perform the following steps to check it:
a. Create a new C# console application.
b. Select the menu "Project" -> "Add New Item...".
c. Double-click the "Applicatio n configuration file" to add a config file.
d. Run the application and see if it will be deleted.

3. It seems to me that file is gone before starting your console
application, I believe that it may be deleted by other process say, VS .NET
IDE. Please use FileMon to find out which process deletes the config file.
You can download FileMon utility at
http://www.sysinternals.com/ntw2k/source/filemon.shtml.

I look forward to your response.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
>I have a simple C# console app that needs to read the appname.exe.con fig
file to get db connect strings etc. from the <appSettings> . When the app
starts, it deletes the file! I can't figure it out. When I set a break point
on the first line in MAIN and check for the file, it is gone!


Yes, the IDE will wipe out the target directory when compiling.

The solution is to add your config file to your project, and make sure
to call it "app.config " (exactly that - DO NOT call it anything else,
DO NOT expand "app" to be your app's name, or anything like that!).

In this case, the VS.NET IDE will always but your app.config file,
renamed to <yourproject.ex e.config>, into your output directory.

Marc
=============== =============== =============== =============== ====
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)i nova.ch
Jul 21 '05 #3
Hi,

Where do you have the file "appname.exe.co nfig"?? in the Bin folder??
I had the same problem with a config file in the bin folder. when th
eproject is compiled it deletes all the bin folder content.

"Richard" <ri************ @matteicos.com> escreveu na mensagem
news:OW******** ******@TK2MSFTN GP10.phx.gbl...
I have a simple C# console app that needs to read the appname.exe.con fig
file to get db connect strings etc. from the <appSettings> . When the app
starts, it deletes the file! I can't figure it out. When I set a break point on the first line in MAIN and check for the file, it is gone!

This is a 4 hour app, but I have spent all day trying to understand why the config file is being deleted. Any help would be greatly appreciated.

Thanks very much in advance,

Richard Kessler

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1335
by: Kyle Blaney | last post by:
Suppose myApp.exe.config contains a redirection from version 1.0 of someAssembly to version 1.1 of someAssembly. When a user deletes myApp.exe.config and version 1.0 of someAssembly is installed on their machine, myApp will continue to run but will use version 1.0 of someAssembly. This is worse than the behaviour when a user deletes an...
3
511
by: Richard | last post by:
I have a simple C# console app that needs to read the appname.exe.config file to get db connect strings etc. from the <appSettings>. When the app starts, it deletes the file! I can't figure it out. When I set a break point on the first line in MAIN and check for the file, it is gone! This is a 4 hour app, but I have spent all day trying to...
6
1441
by: yaron | last post by:
Hi all, I want to give a sample console application for the user with 2 configuration files. I want to give also a 2 .bat files for running the sample application, one for each configuration file. How can i choose in the .bat file which configuration file to use ? (something like myApp.exe -D file1.config). Thanks.
2
5140
by: Vikram | last post by:
I am using log4net in a vb.net console application. But its not working. I have added congif setting in app.config file also No error is generated but app. does not write to log file. app.config file: <?xml version="1.0" encoding="utf-8" ?>
2
525
by: Jim Heavey | last post by:
Hello, I used VS 2005 to create a console application. Got the application working just fine. I then decided I would create a folder for each of my "console" applications within that project. I created a new folder and placed the working application under tht folder (This included the .config file, the driver .cs (void main) and the class...
1
2031
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following error: The CLR has been unable to transition from COM context 0x1a2008 to COM context 0x1a2178 for 60 seconds. The thread that owns the destination...
6
1790
by: keeps21 | last post by:
I'm having a bit of trouble creating a page to delete a story from the content table in my database. I have checked my DELETE query directly in phpmyadmin and it is working fine. I am echoing the query to check that it comes out as expected and it looks fine. The problem seems to be that when my code is run the record never gets deleted....
0
1299
by: Reg | last post by:
Hello All! I have a small Console based Application which acts like Http server. HttpListener is used for Http requests and responses. Now I would like to use Digest Authentication and I made a IHttpModule based assembly to handle authentication. Problem is that IHttpModeule based assembly is configured into web.config but I don't know...
1
8351
by: mquincey | last post by:
One of the features offered by .NET 2.0 is the use of the TraceSource class. In an attempt to demonstrate its use, I wanted to run my test under the following conditions: 1. Use TraceSource class (Not Trace or Debug classes) 2. Set up the trace solution in the application's application.config file 3. Use Visual Basic.NET to test the...
0
7459
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7726
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7967
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5377
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1953
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.