Click here to Skip to main content
15,915,600 members
Home / Discussions / C#
   

C#

 
AnswerRe: Localization of data Pin
dead_link29-Nov-06 8:10
dead_link29-Nov-06 8:10 
QuestionStrange reaction from a DataGridView Pin
~~~Johnny~~~29-Nov-06 7:05
~~~Johnny~~~29-Nov-06 7:05 
QuestionXmlDocument - Browser View Pin
h@s@n29-Nov-06 6:46
h@s@n29-Nov-06 6:46 
QuestionRe: XmlDocument - Browser View Pin
loneferret29-Nov-06 7:29
loneferret29-Nov-06 7:29 
AnswerRe: XmlDocument - Browser View Pin
h@s@n29-Nov-06 7:46
h@s@n29-Nov-06 7:46 
QuestionGet Current Process Pin
Now_Loading29-Nov-06 5:59
Now_Loading29-Nov-06 5:59 
AnswerRe: Get Current Process Pin
Eric Dahlvang29-Nov-06 6:45
Eric Dahlvang29-Nov-06 6:45 
Questionis inaccessible due to its protection level Pin
dterry45829-Nov-06 5:28
dterry45829-Nov-06 5:28 
I am getting the following error when trying to compile this code:

H:\Grid Project\Alchemi-1.0.4-src\src\Alchemi.ManagerServiceController\ManagerMainForm.cs(61): 'ManagerTemplateForm.components' is inaccessible due to its protection level

Here is the code that I am working with. I have a comment on the line where the error is thrown.


#region Alchemi copyright and license notice

/*
* Alchemi [.NET Grid Computing Framework]
* http://www.alchemi.net
*
* Title			:	ManagerMainForm.cs
* Project		:	Alchemi Manager Application
* Created on	:	2003
* Copyright		:	Copyright © 2006 The University of Melbourne
*					This technology has been developed with the support of 
*					the Australian Research Council and the University of Melbourne
*					research grants as part of the Gridbus Project
*					within GRIDS Laboratory at the University of Melbourne, Australia.
* Author         :  Akshay Luther (akshayl@csse.unimelb.edu.au), Rajkumar Buyya (raj@csse.unimelb.edu.au), and Krishna Nadiminti (kna@csse.unimelb.edu.au)
* License        :  GPL
*					This program is free software; you can redistribute it and/or 
*					modify it under the terms of the GNU General Public
*					License as published by the Free Software Foundation;
*					See the GNU General Public License 
*					(http://www.gnu.org/copyleft/gpl.html) for more details.
*
*/ 
#endregion

using System;
using System.ComponentModel;
using System.Reflection;
using System.ServiceProcess;
using System.Threading;
using System.Windows.Forms;
using Alchemi.Core;
using Alchemi.Core.Manager;
using Alchemi.Manager;
using log4net;


// Configure log4net using the .config file
[assembly: log4net.Config.XmlConfigurator(Watch=true)]

namespace Alchemi.ManagerService
{
	public class ManagerMainForm : ManagerTemplateForm
	{
		public const string serviceName = "Alchemi Manager Service";

		public ManagerMainForm():base()
		{
			InitializeComponent();
			this.Text = "Alchemi Manager Service Controller";
			Logger.LogHandler += new LogEventHandler(LogHandler);
		}

		#region Windows Form 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()
		{
			this.components = new System.ComponentModel.Container(); <big>//Here is where it errors out at</big>
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ManagerMainForm));
			this.SuspendLayout();
			// 
			// cbIntermediate
			// 
			this.cbIntermediate.CheckedChanged += new System.EventHandler(this.cbIntermediate_CheckedChanged);
			// 
			// ManagerMainForm
			// 
			this.Name = "ManagerMainForm";
			this.Text = "Alchemi Manager";
			this.Load += new System.EventHandler(this.ManagerMainForm_Load);
			this.ResumeLayout(false);
		}
		#endregion

		//-----------------------------------------------------------------------------------------------    

		private void LogHandler(object sender, LogEventArgs e)
		{
			// Create a logger for use in this class
			ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
			switch (e.Level)
			{
				case LogLevel.Debug:
					string message = e.Source  + ":" + e.Member + " - " + e.Message;
					logger.Debug(message,e.Exception);
					break;
				case LogLevel.Info:
					logger.Info(e.Message);
					break;
				case LogLevel.Error:
					logger.Error(e.Message,e.Exception);
					break;
				case LogLevel.Warn:
					logger.Warn(e.Message, e.Exception);
					break;
			}
		}
    
		//-----------------------------------------------------------------------------------------------    

		private void ManagerMainForm_Load(object sender, EventArgs e)
		{
			//this is a service. just read the config.
			ReadManagerConfig(false);
			
			RefreshUIControls();
			btStart.Focus();
		}

		private void ReadManagerConfig(bool useDefault)
		{
			//in case it is a service, the container would be null since we dont need it really.
			//but we still need to get the config from it, so create a new one and read the config.
			ManagerContainer mc = new ManagerContainer();
			mc.ReadConfig(useDefault);
			Config = mc.Config;
			mc = null;
		}

		//-----------------------------------------------------------------------------------------------    

		private void cbIntermediate_CheckedChanged(object sender, EventArgs e)
		{
			Config.Intermediate = cbIntermediate.Checked;
			_container.Config = Config;
			RefreshUIControls();
		}

		#region Implementation of methods from ManagerTemplateForm
		protected override bool Started
		{
			get
			{
				bool started = false;
				try
				{
					ServiceController sc = new ServiceController(serviceName);
					if (sc.Status == ServiceControllerStatus.Running || sc.Status == ServiceControllerStatus.StartPending)
					{
						started = true;
					}
					sc = null;
				}
				catch (Exception ex)
				{
					logger.Error("Error trying to determine service status",ex);
				}
				return started;
			}
		}
		protected override void Exit()
		{
			//for the service controller, we dont stop the manager. we simply end the service-controller.
			this.Close();
			Application.Exit();
		}

		protected override void ResetManager()
		{
			//only reset the GUI.
			ReadManagerConfig(true);
			RefreshUIControls();
		}
     
		protected override void StopManager()
		{
			if (!Started)
			{
				Log("The Manager Service is already stopped.");
				RefreshUIControls();
				return;
			}

			try
			{
				statusBar.Text = "Stopping Manager Service...";
				Log("Stopping Manager Service...");

				btStop.Enabled = false; //to avoid clicking on this again.
				ServiceController sc = new ServiceController(serviceName);
				if (sc.CanStop)
				{
					sc.Stop();
					sc.WaitForStatus(ServiceControllerStatus.Stopped,new TimeSpan(0,0,28));
					Log("Manager Service stopped.");
				}
				else
				{
					logger.Debug("Couldnot stop service: CanStop = false");	
				}
			}
			catch (TimeoutException)
			{
				Log("Timeout expired trying to stop Manager Service.");
			}
			catch (Exception ex)
			{
				Log("Error stopping ManagerService");
				logger.Error(ex.Message, ex);
			}
			RefreshUIControls();

		}
    
		protected override void StartManager()
		{
			if (Started)
			{
				Log("Manager Service is already started.");
				RefreshUIControls();
				return;
			}

			try
			{
				//to avoid people from clicking this again during the start process!
				btStart.Enabled = false;
				btReset.Enabled = false;
				btStop.Enabled = false;

				statusBar.Text = "Starting Manager Service...";

				Log("Attempting to start Manager Service...");

				ServiceController sc = new ServiceController(serviceName);
				if (sc.Status != ServiceControllerStatus.Running && sc.Status != ServiceControllerStatus.StartPending)
				{
					//get latest config from UI and serialize the  object, so that the service uses the latest config.
					Config = GetConfigFromUI();
					if (Config!=null)
					{					
						Config.Slz();
					}
					sc.Start();
					sc.WaitForStatus(ServiceControllerStatus.Running,new TimeSpan(0,0,28));
					Log("Manager Service started.");
				}
			}
			catch (TimeoutException)
			{
				Log("Timeout expired trying to start Manager Service.");
			}
			catch (Exception ex)
			{
				Log("Error starting ManagerService");
				logger.Error("Error starting ManagerService",ex);
				StopManager();
			}
			RefreshUIControls();
		}
		#endregion

	}
}

AnswerRe: is inaccessible due to its protection level Pin
BlaiseBraye29-Nov-06 7:16
BlaiseBraye29-Nov-06 7:16 
QuestionHow to Select Datagridview certain cell (Urgent) Pin
mohamedyahyaelzayat29-Nov-06 4:49
mohamedyahyaelzayat29-Nov-06 4:49 
AnswerRe: How to Select Datagridview certain cell (Urgent) Pin
ednrgc29-Nov-06 5:02
ednrgc29-Nov-06 5:02 
GeneralRe: How to Select Datagridview certain cell (Urgent) Pin
mohamedyahyaelzayat29-Nov-06 5:22
mohamedyahyaelzayat29-Nov-06 5:22 
GeneralRe: How to Select Datagridview certain cell (Urgent) Pin
ednrgc29-Nov-06 6:39
ednrgc29-Nov-06 6:39 
GeneralRe: How to Select Datagridview certain cell (Urgent) Pin
mohamedyahyaelzayat29-Nov-06 23:23
mohamedyahyaelzayat29-Nov-06 23:23 
AnswerRe: How to Select Datagridview certain cell (Urgent) Pin
Eric Dahlvang29-Nov-06 5:50
Eric Dahlvang29-Nov-06 5:50 
GeneralRe: How to Select Datagridview certain cell (Urgent) Pin
mohamedyahyaelzayat29-Nov-06 5:58
mohamedyahyaelzayat29-Nov-06 5:58 
QuestionDatabinding to a textbox (Urgent) Pin
Saira Tanwir29-Nov-06 3:51
Saira Tanwir29-Nov-06 3:51 
AnswerRe: Databinding to a textbox (Urgent) Pin
Eduard Keilholz29-Nov-06 4:10
Eduard Keilholz29-Nov-06 4:10 
GeneralRe: Databinding to a textbox (Urgent) Pin
Saira Tanwir29-Nov-06 4:22
Saira Tanwir29-Nov-06 4:22 
QuestionMy app works on the PC but not on the Smart Device - I'm desperate! Pin
Dewald29-Nov-06 3:49
Dewald29-Nov-06 3:49 
QuestionListView [Details View] Pin
h@s@n29-Nov-06 3:40
h@s@n29-Nov-06 3:40 
AnswerRe: ListView [Details View] Pin
dead_link29-Nov-06 6:50
dead_link29-Nov-06 6:50 
QuestionDisplaying Certain Folders & Subs in Treeview Pin
loneferret29-Nov-06 3:18
loneferret29-Nov-06 3:18 
AnswerRe: Displaying Certain Folders & Subs in Treeview Pin
Scott Dorman29-Nov-06 3:56
professionalScott Dorman29-Nov-06 3:56 
GeneralRe: Displaying Certain Folders & Subs in Treeview Pin
loneferret29-Nov-06 7:28
loneferret29-Nov-06 7:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.