473,666 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple settings files

I have created a class library (DLL) that requires a certain XML file in the
same directory as the DLL. This XML file is essentially a configuration or
settings file but I want it to be a separate file from the standard
user.config file. My attempts to do this did not yield what I needed:

(1) I first thought of just using a separate Settings object in my project,
but I observed that that simply inserts a separate section in user.config,
not a separate file as I require.

(2) I next tried just a plain XML file that I could read/write manually. I
could then add a post-build command to copy this file to the bin directory
when I create my DLL. That's fine for building the library itself but if I
add this library into another project as a reference how could I
automatically bring the XML file along as well?

Is there a different (better?) way to do something like this?

Nov 20 '08 #1
3 3801
"michael sorens" <m_********@new sgroup.nospamwr ote in message
news:F3******** *************** ***********@mic rosoft.com...
>I have created a class library (DLL) that requires a certain XML file in
the
same directory as the DLL. This XML file is essentially a configuration or
settings file but I want it to be a separate file from the standard
user.config file. My attempts to do this did not yield what I needed:

(1) I first thought of just using a separate Settings object in my
project,
but I observed that that simply inserts a separate section in user.config,
not a separate file as I require.

(2) I next tried just a plain XML file that I could read/write manually. I
could then add a post-build command to copy this file to the bin directory
when I create my DLL. That's fine for building the library itself but if I
add this library into another project as a reference how could I
automatically bring the XML file along as well?

Is there a different (better?) way to do something like this?

With option (2) have you tried to test the existence of the file, and if it
does not exist, simply create it with defaults? When your dll first needs
it, it could request the user to setup some settings. With this approach,
the client to your dll could either not create the file, or somehow setup
one where it installs your dll.

Nov 20 '08 #2
Hi Michael,

As for the scenario you mentioned, I think the best approach is storing the
data into the built-in configuration section(such as AppSetting or a custom
config section). Thus, you can use .NET standard configuration API to load
it.

Since you want to separate the file, you can consider Mike's suggestion
about define a internal method which can programmtically generate a default
template(of that xml file). Thus, if the target application hasn't copied
the XML file(together with the dll), your internal method will autogenerate
one. For the template xml file, you can consider storing it in
dll/assembly's embeded resource:

#Understanding Embedded Resources in Visual Studio .NET
http://www.codeproject.com/KB/dotnet...resources.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: =?Utf-8?B?bWljaGFlbCB zb3JlbnM=?= <m_********@new sgroup.nospam>
Subject: multiple settings files
Date: Wed, 19 Nov 2008 19:38:00 -0800
>
I have created a class library (DLL) that requires a certain XML file in
the
>same directory as the DLL. This XML file is essentially a configuration or
settings file but I want it to be a separate file from the standard
user.config file. My attempts to do this did not yield what I needed:

(1) I first thought of just using a separate Settings object in my
project,
>but I observed that that simply inserts a separate section in user.config,
not a separate file as I require.

(2) I next tried just a plain XML file that I could read/write manually. I
could then add a post-build command to copy this file to the bin directory
when I create my DLL. That's fine for building the library itself but if I
add this library into another project as a reference how could I
automaticall y bring the XML file along as well?

Is there a different (better?) way to do something like this?

Nov 20 '08 #3
Thanks to your pointers I discovered that embedded resources is the key to
what I need. I added my file as a resource, then during startup I check for
its existence as a file and create the file from the resource if it is not
already there.
(I found this additional link on Adding and Editing Resources most useful:
http://msdn.microsoft.com/en-us/library/7k989cfy.aspx.)

Nov 21 '08 #4

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

Similar topics

2
11187
by: AMT2K5 | last post by:
Hello. When I compile my program I recieve lots and lots of the following message which I am trying to decipher. "xxx was declared deprecated". What exactly does that mean?
11
5294
by: Mike | last post by:
Looking to find any information on how to properly configure multiple instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking for information on how the multiple instance settings should configured to work, how memory is shared or not, etc. I can not seem to find any good links to this information. Thanks, Mike
2
2178
by: SenthilVel | last post by:
HI all in my visual studio DOtnet . i am not able to open multiple cs files in the projects , its openings only one cs file at a time, can any one let me know, what setttings i must do in order to get all the CS files to edit so that i can see all the files opened. Thanks Senthil
6
539
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by surfin it in multiple browsers simultaneously the site generates a generic runtime error after awhile. I'm thinking this has something to do with my access database and multiple connections. I'm using forms authentication with a login page. Is...
5
10513
by: BPearson | last post by:
Hello I would like to have several sites share a single web.config file. To accomplish this, I would point the root of these sites to the same folder. Is there any reason why I might not want to do this? (IIS 5 or 6 In case you're wondering why I would do this, we have many web sites on a single server, and there are groups of sites that need to share common configuration information. I'd like to ease some administration by having one...
2
1744
by: Sean | last post by:
I have an ASP.NET web application that needs to be rolled out to a number of clients. The functionality is the same in all applications, but each client has its own database. At the moment, I have one application per client, but most of the files in the applications are the same, so this is not ideal from a maintenance point of view. The only differences between the client applications are:
5
11000
by: George | last post by:
Hi, Is it possible to specify the location of a web.config file in an ASP.NET application? I have one ASP.NET application which is to be hosted on 2 web sites in the same web server. I want to configure the 2nd web site as virtual directory so that the 2 web sites are pointing to the same application. However, there are different configuration settings for the 2 web sites, so that accessing these 2 sites' same ASP.NET application will...
5
2231
by: vj | last post by:
Hi all, I am using C++Builder-5. I want to run multiple cpp files at the same time. If I use the C++Builder for running a cpp file (i.e., I just double click the cpp file, it then opens in the C++Builder, where I have the option to 'Run' it), I can't run multiple files, since the Run option is grayed out if one cpp file is already running. I have another option of running the multiple files: from the command prompt (i.e. opening a...
0
1224
by: Fidencio | last post by:
I have multiple projects that each have their own "My.Settings" configuration files. Is it possible to access the my.settings variables from other project's setting files? Let me give an example: I have 2 projects. In the first project, I use the my.settings feature of VS2005. I add a User setting called "RetrieveAll" It is defined as a boolean datatype. In my second project, I would like to access the variable "RetrieveAll" from...
0
8443
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7385
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1772
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.