PC Review


Reply
Thread Tools Rate Thread

can vb.net2003 create config file in bin directory?

 
 
Rich
Guest
Posts: n/a
 
      2nd Mar 2004
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

 
Reply With Quote
 
 
 
 
jim
Guest
Posts: n/a
 
      2nd Mar 2004
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" <(E-Mail Removed)> wrote in message
news:593a01c40079$d2481a40$(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Rich
Guest
Posts: n/a
 
      2nd Mar 2004
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" <(E-Mail Removed)> wrote in

message
>news:593a01c40079$d2481a40$(E-Mail Removed)...
>> 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
>>

>
>
>.
>

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      2nd Mar 2004
* "Rich" <(E-Mail Removed)> 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/>
 
Reply With Quote
 
Rich
Guest
Posts: n/a
 
      2nd Mar 2004
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" <(E-Mail Removed)> 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/>
>.
>

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      3rd Mar 2004
* "Rich" <(E-Mail Removed)> 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/>
 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      3rd Mar 2004
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" <(E-Mail Removed)> wrote in message
news:5dce01c4008a$68c4a0a0$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in

> message
> >news:593a01c40079$d2481a40$(E-Mail Removed)...
> >> 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
> >>

> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help to put directory path to app.config file Vicky via DotNetMonster.com Microsoft Dot NET Framework Forms 1 13th May 2005 12:11 AM
help to put directory path to app.config file Vicky via DotNetMonster.com Microsoft C# .NET 5 12th May 2005 08:22 PM
.config file if app directory moves? skull_leader7@yahoo.com Microsoft VB .NET 0 25th Mar 2005 11:28 PM
Web.config problem I think in doing a Copy Project in vs.net2003 Trint Smith Microsoft ASP .NET 1 4th Mar 2004 05:49 AM
Why I can't change install directory of vs.net2003? Simon Peng Microsoft Dot NET 1 30th Sep 2003 09:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:28 PM.