473,382 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

can vb.net2003 create config file in bin directory?

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
6 2249
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
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
* "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
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
* "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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ferg | last post by:
I've checked all the FAQs and help - spent a couple of hours on this now and it's really bugging me. I've got Moin 1.3.5 installed on IIS 5.0. I can view and edit pages without any problems, but...
9
by: ALI-R | last post by:
Hi,, I have two questions : 1) Is it mandatory that config file of a desktop application must be App.config 2) Is it possible to update config file in your code?? thanks for your help. ALI
2
by: Vicky via DotNetMonster.com | last post by:
Hi, Could anyone help me with some info how to create app.config file. I need to put code of directory info in there, Thank you very much! DirectoryInfo di = new DirectoryInfo("C:\\Vicky...
0
by: Zal | last post by:
have tried to follow the following instructions but to no success, hope someone can help me I have 2 servers server1 and server2. Server1 is the domain server, running sbs2003, i have gone to...
2
by: PMac | last post by:
I'm trying to execute a stand-alone console application from an aspx page when a use clicks a button on that page. On the aspx page is the following lines of pertinent code: private void...
10
by: robwharram | last post by:
Hi, I'm quite frustrated in the fact that I can't even display a simple "Hello World" message on .Net. I've been through all of the groups and searched all over the place and haven't been able...
9
by: Benny Ng | last post by:
Hi,all, How to let the sub-directory to avoid the authentication control from Root's webconfig? I heard that we can add a new web.config to the sub-directory. And then we can slove the problem....
2
by: Luke Dalessandro | last post by:
I have an application with the following layout /root/ /root/Default.aspx /root/web.config /root/child/ /root/child/web.config web.config has a custom configuration section "testSection"...
16
by: Mich | last post by:
Hi, i'm building an web application for anonymous users. They can take a look in the website, nothing more. In order to perform other actions, the anonymous user must be logged. So i create an...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.