English 中文(简体)
ASP.NET project installer registry key?
原标题:

I have a asp.net project, and wrote a web installer. The setup exe/msi copies that project in directory chosen by the installing user, and creates an application for it.

How can I get the path my asp.net application got installed to (in the installer)? I want to write the physical path of my ASP.net application into the registry, because a windows service needs to watch a directory of this web project, and it can t do that, unless it knows where the web project was installed to.

Does the Webinstaller project by any chance write this value into the registry automatically ?

最佳回答

It is possible:

Right-click on the setup project, and choose View->Registry from the context menu.
Right-click on HKEY_Local_Machine, add a new key, call it Software.
Right click on Software, add a new key, call it "MyCompanyName".
Right click on MyCompanyName, from the context-menu, choose new->String call it installation folder.
Left click on the installationFolder key, and set property value to [TARGETDIR]
Add an additional string key, call it version and give it the value [ProductVersion]

including the []


On x64, you ll find your registry key in regedit under
[HKEY_LOCAL_MACHINESOFTWAREWow6432NodeYourCompany]


But programmatically, you can read it normally, from normal projects and web projects, with:
My.Computer.Registry.GetValue("HKEY_CURRENT_USERSoftwareYourCompanyName", "Installation Folder", Nothing)

问题回答

Unfortunately no; IIS uses means other than the registry to store its configuration.

For IIS4, IIS5 and IIS6, you ll need to take a look through the IIS Metabase. This is an XML file in your Windows folder under system32inetsrvMetabase.xml; it s XML, so you should be able to read it directly to find the information you need.

IIS7 doesn t use the Metabase any more; instead, see here for details of the managed API to the IIS configuration.

So you may find it best to rework your application to look in either of these places for the directory information that you need.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签