473,395 Members | 1,677 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,395 software developers and data experts.

.NET dll config file

Hi,
This is a bit with versioning and installation of
the .NET dlls. I want to perform the following, [THIS IS
WITH REFERENCE TO WINDOWS APPLICATION]
1. A third party application will be invoking my .NET dll
through COM interop . For this I have used Regasm and
registered the assembly in the registry with CODEBASE
option.

eg: regasm myDll.dll
/tlb:myDll.tlb /codebase

2.The main dll which is invoked from the third party
application has some other .NET dll references.
These .NET references are common dlls used by many other
similar main dlls. The situation is we had placed this
common dlls in the GAC and it worked fine through
reference.Now we have a business decision to move these
common dll's to a local directory in the users machine
and refer it from there. I have written a Configuration
file and set the <codeBase ...> to point to the
directory. But it is not working. Can anyone send me a
sample config file how it should be. The point of concern
here is , the configuration file should be created for
the Dll and not the Exe.

3. Process Eg:
i. I have a third party application say A ,
ii. I have a set of main assemblies say B,C,D each of
which will be independently invoked by the third party
application A
iii. I have a set of common .NET dll libraries say X,Y,Z
these will be used by the main assemblies B,C and D
Process
The application A will invoke main assembly B (which is
registered in the registry with codebase option) . I have
placed assembly B in a directory say "c:\MainDlls"
The assembly B references X,Y,Z . I want to place these
X,Y,Z dlls in a common directory (not in GAC)
say "C:\CommonDlls" . The other main assemblies C and D
will also use these common libraries from the same
directory.
|---------X
A --------------->B|---------Y
(Third party |---------Z
application)

I have the following question
1.How should be the config file written in this case.Its
for a .NET dll (not .NET exe)
2.Where should the config file be placed. Since its a
third party invokingapplication, not sure where to place
the config file.

Any help will be really appreciated.

Regards,
Suresh Gladstone


Nov 22 '05 #1
2 4811
Suresh,

I hope this article can help you:
http://support.microsoft.com/default...b;en-us;837908

"Suresh Gladstone" wrote:
Hi,
This is a bit with versioning and installation of
the .NET dlls. I want to perform the following, [THIS IS
WITH REFERENCE TO WINDOWS APPLICATION]
1. A third party application will be invoking my .NET dll
through COM interop . For this I have used Regasm and
registered the assembly in the registry with CODEBASE
option.

eg: regasm myDll.dll
/tlb:myDll.tlb /codebase

2.The main dll which is invoked from the third party
application has some other .NET dll references.
These .NET references are common dlls used by many other
similar main dlls. The situation is we had placed this
common dlls in the GAC and it worked fine through
reference.Now we have a business decision to move these
common dll's to a local directory in the users machine
and refer it from there. I have written a Configuration
file and set the <codeBase ...> to point to the
directory. But it is not working. Can anyone send me a
sample config file how it should be. The point of concern
here is , the configuration file should be created for
the Dll and not the Exe.

3. Process Eg:
i. I have a third party application say A ,
ii. I have a set of main assemblies say B,C,D each of
which will be independently invoked by the third party
application A
iii. I have a set of common .NET dll libraries say X,Y,Z
these will be used by the main assemblies B,C and D
Process
The application A will invoke main assembly B (which is
registered in the registry with codebase option) . I have
placed assembly B in a directory say "c:\MainDlls"
The assembly B references X,Y,Z . I want to place these
X,Y,Z dlls in a common directory (not in GAC)
say "C:\CommonDlls" . The other main assemblies C and D
will also use these common libraries from the same
directory.
|---------X
A --------------->B|---------Y
(Third party |---------Z
application)

I have the following question
1.How should be the config file written in this case.Its
for a .NET dll (not .NET exe)
2.Where should the config file be placed. Since its a
third party invokingapplication, not sure where to place
the config file.

Any help will be really appreciated.

Regards,
Suresh Gladstone



Nov 22 '05 #2
Regarding the usage of a config file for a dll:

Currently, the config file is really bound to the exe file. I mean that it
should have the same name and must normally be located in the exe file
directory.

Now, if you want to dedicate a given config file to a dll (and not share the
one of the exe file which initially loaded your dll), you have to create a
new application domain and load the dll in this application domain. This
will give you a chance to specify the config file the application domain
will use.

However, you should note that classes that will be referenced on the second
appdomain from the main appdomain should derive from "MarshalByRefObject"
and they should override the "InitializeLifetimeService" if you plan to have
a long living instance (eg more than 3-4 minutes) referenced from the main
appdomain.

Hope this help,
José

Here is a snippet of how to load a dll in another domain:

//
// Need to isolate the assembly in a new AppDomain in order to be able to
use a customed
// config file [.dll.config]
//
//create the config settings object
AppDomainSetup setup = new AppDomainSetup();

//work out what the config file name and app base are
FileInfo fileInfo = new
FileInfo(Assembly.GetExecutingAssembly().Location) ;
string appBase = fileInfo.DirectoryName;
string configFile = fileInfo.Name + ".config";

//set the app base and the config file
setup.ApplicationBase = appBase;
setup.ConfigurationFile = configFile;

//create the domain
gAppDomain = AppDomain.CreateDomain ("ExportedView: " +
Guid.NewGuid().ToString(), null, setup);

//create the type inside the domain, and get the interface to it
// also define an assembly resolver routine in case the CLR cannot find
our assemblies.
AppDomain.CurrentDomain.AssemblyResolve+=new ResolveEventHandler(
this.MyResolveHandler);

Object o = gAppDomain.CreateInstanceAndUnwrap(
Assembly.GetExecutingAssembly().FullName,
typeof(UFSStatusAccessDomain).FullName);
gUFSStatusAccessDomain = (UFSStatusProvider.UFSStatusAccessDomain)o;

// call the init on the other AppDomain
return gUFSStatusAccessDomain.Init(nTestLevel, out strErrDescr);

.......

//-----------------------------------------------------------------------------------------
/// <summary>
/// This method is used to provide assembly location resolver. It is
called on event as needed by the CLR.
/// Refer to document related to AppDomain.CurrentDomain.AssemblyResolve
/// </summary>
private Assembly MyResolveHandler(object sender,ResolveEventArgs e)
{
string[] file = e.Name.Split( ',' );
string strDir =
Path.GetDirectoryName(Assembly.GetExecutingAssembl y().Location);
Assembly a = Assembly.LoadFrom( strDir + @"\" + file[0] + ".dll" );
return a;
}
"Suresh Gladstone" <su*********@yahoo.com> wrote in message
news:3a****************************@phx.gbl...
Hi,
This is a bit with versioning and installation of
the .NET dlls. I want to perform the following, [THIS IS
WITH REFERENCE TO WINDOWS APPLICATION]
1. A third party application will be invoking my .NET dll
through COM interop . For this I have used Regasm and
registered the assembly in the registry with CODEBASE
option.

eg: regasm myDll.dll
/tlb:myDll.tlb /codebase

2.The main dll which is invoked from the third party
application has some other .NET dll references.
These .NET references are common dlls used by many other
similar main dlls. The situation is we had placed this
common dlls in the GAC and it worked fine through
reference.Now we have a business decision to move these
common dll's to a local directory in the users machine
and refer it from there. I have written a Configuration
file and set the <codeBase ...> to point to the
directory. But it is not working. Can anyone send me a
sample config file how it should be. The point of concern
here is , the configuration file should be created for
the Dll and not the Exe.

3. Process Eg:
i. I have a third party application say A ,
ii. I have a set of main assemblies say B,C,D each of
which will be independently invoked by the third party
application A
iii. I have a set of common .NET dll libraries say X,Y,Z
these will be used by the main assemblies B,C and D
Process
The application A will invoke main assembly B (which is
registered in the registry with codebase option) . I have
placed assembly B in a directory say "c:\MainDlls"
The assembly B references X,Y,Z . I want to place these
X,Y,Z dlls in a common directory (not in GAC)
say "C:\CommonDlls" . The other main assemblies C and D
will also use these common libraries from the same
directory.
|---------X
A --------------->B|---------Y
(Third party |---------Z
application)

I have the following question
1.How should be the config file written in this case.Its
for a .NET dll (not .NET exe)
2.Where should the config file be placed. Since its a
third party invokingapplication, not sure where to place
the config file.

Any help will be really appreciated.

Regards,
Suresh Gladstone



Nov 22 '05 #3

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

Similar topics

13
by: Maxim Khesin | last post by:
I want to have a config file with my python proggie, satisfying the following requirements: 1) support key->(value, default) 2) simple and intuitive to read and edit 3) easyly readable into a...
4
by: Fuzzyman | last post by:
There have been a couple of config file 'systems' announced recently, that focus on building more powerful and complex configuration files. ConfigObj is a module to enable you to much more *simply*...
2
by: Suresh Gladstone | last post by:
Hi, This is a bit with versioning and installation of the .NET dlls. I want to perform the following, 1. A third party application will be invoking my .NET dll through COM interop . For this I...
4
by: grs | last post by:
Can a class library have a app.config file. Reason for asking is that the microsoft application blocks all read from myApp.exe.config. How can you use the application blocks if you do not have an...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
6
by: Rich | last post by:
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?...
13
by: Khodr | last post by:
Hello, I am using VS.NET 2003 and vb. I build my application MyApp and it generates MyApp.exe.config. So now MyApp.exe reads parameters from MyApp.exe.config. Great and no problem! I need to...
3
by: Blasting Cap | last post by:
I am working on a web app that I want to be able to use a separate config file on, in addition to the web.config file that's already working in the application. If I put the following in the...
12
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD...
5
by: mmcd79 | last post by:
I built a VB.net application that makes use of a machine level DB connection string setting, and a user level starting location setting. The machine level setting and the default user based...
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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.