Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to

One of the readers of the my post "Using VS 2005 Web Setup Project with custom actions" asked how to pick web.config file. that is actually part of the web project, from custom action installer class located in a separate DLL.

 With an assumption that DLL with installer class located in the BIN folder of the web project , you can do the following:

Dim asm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim sConfigFileName As String FSHelperLib.AppSettingsHelper.GetConfigFileName(asm)


        public static string GetConfigFileName(Assembly ExecutingAssembly)


            string sPath = "";

            { //root folder one level up from bin

                sPath = SystemHelper.GetWebRootFolder(ExecutingAssembly);

                sPath = sPath + @"\web.config";


            if (!File.Exists(sPath))


                throw new FileNotFoundException("Missing config file " + sPath);


            return sPath;


 See also My SystemHelper class for GetWebRootFolder definition.


Posted on Monday, August 14, 2006 9:13 AM ASP.NET , Deployment | Back to top

Comments on this post: How to open web.config file from custom action installer class, located in DLL.

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Michael Freidgeim | Powered by: