App.config question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi...

Related to my last post, I made an interesting discovery - you can include
an application config file in your project, but it seems that unless it is
named *exactly* App.config *and* it lives in the root directory of the
project, it won't get processed and turned into a <myappname>.exe.config
file. Is there any way to change that?

To give a little background, I have 3 related apps that want to share some
constants and a few objects and routines. There's not really enough code
there to warrant a separate, shared assembly for it, but I wanted to make
sure that all the projects in the solution were using the same small bit of
code, so I reorganized my solution directory tree so that there's a
subdirectory of shared data files and code that they all reference.

Then each of my projects as an app1.cs, app2.cs, app3.cs living at the root
directory. I made project specific subdirectories for the App.config,
App.ico, and AssemblyInfo.cs files for each of the projects and included
those into their respective projects. Logically, it suits my needs well, but
then I ran into this weird case where VS .Net 2003 throws erroneous missing
assembly errors and now this weird behavior - that an application config file
*has* to live in a specific spot and have a specific name to get processed at
all.

I'd thought that app1\App.config would be okay and that would get built into
app1.exe.config as part of the build process but unfortunately not as far as
I can find.

I find it odd that when you Add New Item and choose Application
Configuration File, the dialog box actually does let you name it something
other than App.config even though that will break the build process.

Thanks
_mark
 
Hi

I think this is the IDE's behavior. Basically app.config is just an plain
text XML file. In case there is many XXX.config, so IDE will buildin
recognize app.config as the keyword, based on my research, it did not
provide interface for us to change it.

Also commonly we create projects is based on directory, that is to say each
project has its own folder so that the app.config will not confuse with
each other. And each project will be one assembly,(DLL,EXE), I think it is
not recommended to put a few project's source file into same folder.

For your scenario, IDE have a feature to execute command after the build is
finished.
Specifying Build Events
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html
/vchowSpecifyingCustomBuildEvents.asp

BuildEvents Object Properties, Methods, and Events
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/ht
ml/vxmscprojectitemobjectpropertiesmethodsevents.asp

Common Environment Object Model Objects
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/ht
ml/vxmscprojectitemobjectpropertiesmethodsevents.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Related to my last post, I made an interesting discovery - you can include
an application config file in your project, but it seems that unless it is
named *exactly* App.config *and* it lives in the root directory of the
project, it won't get processed and turned into a <myappname>.exe.config
file. Is there any way to change that?

Yes, that's the way it is, the way it is supposed to be, and the way
it was designed to be, and no, there's no way to change that (as far
as I know).

Marc
================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
 
Hey Mark,

You could have a look at the pre-build and post-build events of VS.NET. All
you have to do is provide *.bat like commands in there and you are off. You
may want to refer to the documentation for fetching predefined paths such as
where your build location resides, ect.

Regards,
Justin
 
Back
Top