[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.setup

Pb setting OverwriteAsNeeded for an event log

Bragadiru

4/6/2006 9:46:00 AM

Hi,

In my setup project I want to create an event log on and set it to Overwrite
as needed.
I'm using this custom action :
[RunInstaller(true)]

public class ClientEventLogInstaller :
System.Configuration.Install.Installer

{

private EventLogInstaller myEventLogInstaller = new EventLogInstaller();

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;

public ClientEventLogInstaller()

{

// This call is required by the Designer.

InitializeComponent();

// TODO: Add any initialization after the InitComponent call

}


public override void Install(IDictionary savedState)

{

myEventLogInstaller.Source = "myLog";

// Set the Log that source is created in

myEventLogInstaller.Log = "myLog";


// Add myEventLogInstaller to the Installers Collection.

Installers.Add(myEventLogInstaller);

base.Install(savedState);

}

protected override void OnCommitted(IDictionary savedState)

{

base.OnCommitted(savedState);

// Add steps to be done after committing an application.

if (EventLog.Exists("myLog")) // it returns TRUE, 'cause I dont get any
exception at runtime (see else)

{

EventLog[] arrEventLogs = EventLog.GetEventLogs();

foreach (EventLog ev in arrEventLogs)

{

if (string.Compare(ev.Log, "myLog", true) == 0)

ev.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded, 5);

}

}

else

throw new InstallException("myLog event log does not exists yet");

}

#region Component Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

components = new System.ComponentModel.Container();

}

#endregion

}


The event log is created, BUT it is NOT set to OverwriteAsNeeded.
What am I doing wrong ?
I'm using VS2005.

Thanks for any advice



1 Answer

Bragadiru

4/13/2006 2:26:00 PM

0

My mistake : I forgot to add the custom action to Commit phase, too. Anyway
after I added it I got the following installing error : The savedState
dictionary contains inconsistent data and might have been corrupted.

Finally, I fixed by delete it from Commmit and move the code from
OnCommitted method to next Custom Action dll => everything is fine now.


"Bragadiru" <adi_lazar@nospam.nospam> wrote in message
news:ePVUU8VWGHA.1204@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> In my setup project I want to create an event log on and set it to
> Overwrite as needed.
> I'm using this custom action :
> [RunInstaller(true)]
>
> public class ClientEventLogInstaller :
> System.Configuration.Install.Installer
>
> {
>
> private EventLogInstaller myEventLogInstaller = new EventLogInstaller();
>
> /// <summary>
>
> /// Required designer variable.
>
> /// </summary>
>
> private System.ComponentModel.Container components = null;
>
> public ClientEventLogInstaller()
>
> {
>
> // This call is required by the Designer.
>
> InitializeComponent();
>
> // TODO: Add any initialization after the InitComponent call
>
> }
>
>
> public override void Install(IDictionary savedState)
>
> {
>
> myEventLogInstaller.Source = "myLog";
>
> // Set the Log that source is created in
>
> myEventLogInstaller.Log = "myLog";
>
>
> // Add myEventLogInstaller to the Installers Collection.
>
> Installers.Add(myEventLogInstaller);
>
> base.Install(savedState);
>
> }
>
> protected override void OnCommitted(IDictionary savedState)
>
> {
>
> base.OnCommitted(savedState);
>
> // Add steps to be done after committing an application.
>
> if (EventLog.Exists("myLog")) // it returns TRUE, 'cause I dont get any
> exception at runtime (see else)
>
> {
>
> EventLog[] arrEventLogs = EventLog.GetEventLogs();
>
> foreach (EventLog ev in arrEventLogs)
>
> {
>
> if (string.Compare(ev.Log, "myLog", true) == 0)
>
> ev.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded, 5);
>
> }
>
> }
>
> else
>
> throw new InstallException("myLog event log does not exists yet");
>
> }
>
> #region Component Designer generated code
>
> /// <summary>
>
> /// Required method for Designer support - do not modify
>
> /// the contents of this method with the code editor.
>
> /// </summary>
>
> private void InitializeComponent()
>
> {
>
> components = new System.ComponentModel.Container();
>
> }
>
> #endregion
>
> }
>
>
> The event log is created, BUT it is NOT set to OverwriteAsNeeded.
> What am I doing wrong ?
> I'm using VS2005.
>
> Thanks for any advice
>
>
>