-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Mahesh ChandraMouli
Message 2 in Discussion

Hi Vipul,   Take an example, If your application uses classes that inherit from 
System.EnterpriseServices.ServicedComponent these classes must be registered with 
COM+.  ServicedComponents can register automatically the first time they run but this 
works only if the process running them has administrative privileges.  ASP.NET does 
not run with Administrative privileges (unless you set it to run as SYSTEM) so when 
ServicedComponents try to register they will fail with an Access Denied exception.   
The setup project can be configured to execute custom actions as a part of the install 
or uninstall of your application.  All you need to do is to create a class as a part 
of your assembly that inherits from System.Configuration.Install.Installer and add a 
custom install action to your project. To add an installer class to your serviced 
component assembly: 1.      Right click on your serviced component project 2.      
Select Add / New Item� this will display the Add New Item dialog 3.      In the 
Categories pane select Code 4.      In the Templates pane select Installer Class 
Installer Class
In the newly created installer class, you will need to override the Install and 
Uninstall methods.  You can use the System.EnterpriseServices.RegistrationHelper class 
to handle registration and un-registration during install and un-install. Install
At installation time the registration helper class will return the ApplicationID of 
the newly created COM+ application.  The Install class passes an IDictionary interface 
that you can use to save state captured during installation.  You will need to save 
the Assembly name and the AppID to use later during un-install.   Tip: If an exception 
occurs during installation, the installer will display the exception text which may 
leave users confused.  A best practice is to capture the exception text to a log file 
and display a user friendly exception message instead.   public override void 
Install(System.Collections.IDictionary stateSaver) {       try        {             
string AppID = null;             string TypeLib = null;             // Get the 
location of the current assembly             string Assembly = 
GetType().Assembly.Location;             // Install the application             
RegistrationHelper rh = new RegistrationHelper (); rh.InstallAssembly (Assembly, ref 
AppID, ref TypeLib, InstallationFlags.FindOrCreateTargetApplication);             // 
Save the state - you will need this for the uninstall             stateSaver.Add 
("AppID", AppID);             stateSaver.Add ("Assembly", Assembly);       }       
catch(Exception ex)       { #if DEBUG             Debug.WriteLine (ex); #endif         
    StreamWriter sw = File.AppendText ("InstallError.log");             sw.WriteLine 
("Uninstall Error: {0}", ex.Message);             // If the installer catches the 
exception it will display              // an error message.  Show a friendly error 
message             throw new ApplicationException( "Error installing the middle 
tier", ex);       } }       Checkout this sample also 
http://www.c-sharpcorner.com/Code/2003/Dec/CustomInstallMG.asp     Regards Mahesh 
ChandraMouli Microsoft .NET MVP|MCAD

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to