By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,469 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,469 IT Pros & Developers. It's quick & easy.

can vb.net2003 create config file in bin directory?

P: n/a
Hello,

I picked up this example on using the Reflection namespace
for loading forms/classes on the fly at msdn

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnadvnet/html/vbnet10082002.asp

which uses a config file named "yourAppName.exe.config"
which is an xml based config file that references dlls in
other projects to load their forms/classes on the fly.
This config file resides in the bin directory of the
app's .exe. The example works great (although written in
vb.net2002 - for vb.net2003 need to instantiate a var:
ClassConfigValues = New Specialized.NameValueCollection )

The problem I am having is that when I run the app in
debug mode - the app's bin gets recreated each time, and I
have to manually recreate/copy the config file into the
bin. The config file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="availableclasses"
type="System.Configuration.NameValueSectionHandler " />
</configSections>
<availableclasses>
<add key="First Form"
value="C:\Newforms\FirstForm.dll~FirstForm.Form1"> </add>
<add key="Second Form"
value="C:\Newforms\SecondForm.dll~SecondForm.Form1 "></add>
<add key="Third Form"
value="C:\Newforms\ThirdForm.dll~ThirdForm.Form1"> </add>
</availableclasses>
</configuration>

Is there a way for vb.net2003 to add this config file to
the bin at rebuild time? Or is it a deal where you create
the app and manually add the file yourself?

Thanks,
Rich

Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
jim
hi rich,

just add the config file to your solution with the (default) name of
App.Config... when you build your project/solution App.Config will be
automatically renamed and moved to the bin directory.

hope this helps,

jim

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:59****************************@phx.gbl...
Hello,

I picked up this example on using the Reflection namespace
for loading forms/classes on the fly at msdn

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnadvnet/html/vbnet10082002.asp

which uses a config file named "yourAppName.exe.config"
which is an xml based config file that references dlls in
other projects to load their forms/classes on the fly.
This config file resides in the bin directory of the
app's .exe. The example works great (although written in
vb.net2002 - for vb.net2003 need to instantiate a var:
ClassConfigValues = New Specialized.NameValueCollection )

The problem I am having is that when I run the app in
debug mode - the app's bin gets recreated each time, and I
have to manually recreate/copy the config file into the
bin. The config file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="availableclasses"
type="System.Configuration.NameValueSectionHandler " />
</configSections>
<availableclasses>
<add key="First Form"
value="C:\Newforms\FirstForm.dll~FirstForm.Form1"> </add>
<add key="Second Form"
value="C:\Newforms\SecondForm.dll~SecondForm.Form1 "></add>
<add key="Third Form"
value="C:\Newforms\ThirdForm.dll~ThirdForm.Form1"> </add>
</availableclasses>
</configuration>

Is there a way for vb.net2003 to add this config file to
the bin at rebuild time? Or is it a deal where you create
the app and manually add the file yourself?

Thanks,
Rich

Nov 20 '05 #2

P: n/a
Cool! I learned something new. That worked great. One
question though on this example. The big deal is that it
says with Reflection you can instantiate forms/classes on
the fly which are created later and in a different
project. But from what I understand, you have to include
a reference to these new objects in the config file which
suggests that you will have prior knowledge of the
existence of these objects. Wait. I think I am answering
my own question - you can add this config file at a later
time. So my original question of do you manually plant
the config would be either or. I could include a config
file in the solution or I could add a config file after
the fact. Well, anyway, I learned something :). I guess
the real deal is to stuff these two guys for just-in-case.

Imports System.Configuration
Imports System.Reflection

Rich

-----Original Message-----
hi rich,

just add the config file to your solution with the (default) name ofApp.Config... when you build your project/solution App.Config will beautomatically renamed and moved to the bin directory.

hope this helps,

jim

"Rich" <an*******@discussions.microsoft.com> wrote in messagenews:59****************************@phx.gbl...
Hello,

I picked up this example on using the Reflection namespace for loading forms/classes on the fly at msdn

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnadvnet/html/vbnet10082002.asp

which uses a config file named "yourAppName.exe.config"
which is an xml based config file that references dlls in other projects to load their forms/classes on the fly.
This config file resides in the bin directory of the
app's .exe. The example works great (although written in vb.net2002 - for vb.net2003 need to instantiate a var:
ClassConfigValues = New Specialized.NameValueCollection )
The problem I am having is that when I run the app in
debug mode - the app's bin gets recreated each time, and I have to manually recreate/copy the config file into the
bin. The config file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="availableclasses"
type="System.Configuration.NameValueSectionHandler " />
</configSections>
<availableclasses>
<add key="First Form"
value="C:\Newforms\FirstForm.dll~FirstForm.Form1"> </add>
<add key="Second Form"
value="C:\Newforms\SecondForm.dll~SecondForm.Form1 "></add> <add key="Third Form"
value="C:\Newforms\ThirdForm.dll~ThirdForm.Form1"> </add>
</availableclasses>
</configuration>

Is there a way for vb.net2003 to add this config file to
the bin at rebuild time? Or is it a deal where you create the app and manually add the file yourself?

Thanks,
Rich

.

Nov 20 '05 #3

P: n/a
* "Rich" <an*******@discussions.microsoft.com> scripsit:
which uses a config file named "yourAppName.exe.config"
which is an xml based config file that references dlls in
other projects to load their forms/classes on the fly.
This config file resides in the bin directory of the
app's .exe. The example works great (although written in
vb.net2002 - for vb.net2003 need to instantiate a var:
ClassConfigValues = New Specialized.NameValueCollection )

The problem I am having is that when I run the app in
debug mode - the app's bin gets recreated each time, and I
have to manually recreate/copy the config file into the
bin. The config file looks like this:


Rename the file to "App.config", put it in the project's source folder
and add it to the project. VS.NET will automatically copy the file to
the "bin" directory and rename it appropriately.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Nov 20 '05 #4

P: n/a
Thank you. I did that now, and it worked fine. May I ask
if it is possible to create/generate an App.Config file
from within the code? For example, if I have an already
existing app (with all the required imports), and I want
to reference some new objects (forms/classes) from another
project, can I input their information into my existing
app like through a form textboxes such as to generate the
config file on the fly or does that require recompiling?
Or is it possible to just create/generate an app.config
file from within the code at all?

Thanks,
Rich
-----Original Message-----
* "Rich" <an*******@discussions.microsoft.com> scripsit:
which uses a config file named "yourAppName.exe.config"
which is an xml based config file that references dlls in other projects to load their forms/classes on the fly.
This config file resides in the bin directory of the
app's .exe. The example works great (although written in vb.net2002 - for vb.net2003 need to instantiate a var:
ClassConfigValues = New Specialized.NameValueCollection )
The problem I am having is that when I run the app in
debug mode - the app's bin gets recreated each time, and I have to manually recreate/copy the config file into the
bin. The config file looks like this:
Rename the file to "App.config", put it in the project's

source folderand add it to the project. VS.NET will automatically copy the file tothe "bin" directory and rename it appropriately.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
.

Nov 20 '05 #5

P: n/a
* "Rich" <an*******@discussions.microsoft.com> scripsit:
Thank you. I did that now, and it worked fine. May I ask
if it is possible to create/generate an App.Config file
from within the code? For example, if I have an already
existing app (with all the required imports), and I want
to reference some new objects (forms/classes) from another
project, can I input their information into my existing
app like through a form textboxes such as to generate the
config file on the fly or does that require recompiling?
Or is it possible to just create/generate an app.config
file from within the code at all?


You won't need to recompile, that's the main advantage of a config
file. Nevertheless, config files should not be used to store user
preferences. You can edit them with .NET's 'System.Xml' classes.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Nov 20 '05 #6

P: n/a
Rich,
I normally include a skeleton config file when I deploy my app, then add new
specific types later.

As normally I am either loading a collection of dynamic types, using a
DictionarySectionHandler. Or I have a "default" implementation of a single
dynamic type, that the end user is able to replace later.

Also giving the skeleton config file, allows the end user (and me!) to know
the correct syntax to use to add the new dynamic type later...

Hope this helps
Jay

"Rich" <an*******@discussions.microsoft.com> wrote in message
news:5d****************************@phx.gbl...
Cool! I learned something new. That worked great. One
question though on this example. The big deal is that it
says with Reflection you can instantiate forms/classes on
the fly which are created later and in a different
project. But from what I understand, you have to include
a reference to these new objects in the config file which
suggests that you will have prior knowledge of the
existence of these objects. Wait. I think I am answering
my own question - you can add this config file at a later
time. So my original question of do you manually plant
the config would be either or. I could include a config
file in the solution or I could add a config file after
the fact. Well, anyway, I learned something :). I guess
the real deal is to stuff these two guys for just-in-case.

Imports System.Configuration
Imports System.Reflection

Rich

-----Original Message-----
hi rich,

just add the config file to your solution with the

(default) name of
App.Config... when you build your project/solution

App.Config will be
automatically renamed and moved to the bin directory.

hope this helps,

jim

"Rich" <an*******@discussions.microsoft.com> wrote in

message
news:59****************************@phx.gbl...
Hello,

I picked up this example on using the Reflection namespace for loading forms/classes on the fly at msdn

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnadvnet/html/vbnet10082002.asp

which uses a config file named "yourAppName.exe.config"
which is an xml based config file that references dlls in other projects to load their forms/classes on the fly.
This config file resides in the bin directory of the
app's .exe. The example works great (although written in vb.net2002 - for vb.net2003 need to instantiate a var:
ClassConfigValues = New Specialized.NameValueCollection )
The problem I am having is that when I run the app in
debug mode - the app's bin gets recreated each time, and I have to manually recreate/copy the config file into the
bin. The config file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="availableclasses"
type="System.Configuration.NameValueSectionHandler " />
</configSections>
<availableclasses>
<add key="First Form"
value="C:\Newforms\FirstForm.dll~FirstForm.Form1"> </add>
<add key="Second Form"
value="C:\Newforms\SecondForm.dll~SecondForm.Form1 "></add> <add key="Third Form"
value="C:\Newforms\ThirdForm.dll~ThirdForm.Form1"> </add>
</availableclasses>
</configuration>

Is there a way for vb.net2003 to add this config file to
the bin at rebuild time? Or is it a deal where you create the app and manually add the file yourself?

Thanks,
Rich

.

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.