Click here to Skip to main content
15,896,118 members
Home / Discussions / C#
   

C#

 
GeneralRe: dropdown controls Pin
leesamanth5-May-05 7:43
leesamanth5-May-05 7:43 
GeneralC# IDE question Pin
hongheo764-May-05 11:11
hongheo764-May-05 11:11 
GeneralRe: C# IDE question Pin
MoustafaS4-May-05 13:54
MoustafaS4-May-05 13:54 
GeneralUpload file Pin
vuthaianh4-May-05 7:38
vuthaianh4-May-05 7:38 
GeneralRe: Upload file Pin
Polis Pilavas4-May-05 10:59
Polis Pilavas4-May-05 10:59 
GeneralTableLayoutPanel (Whidbey) Pin
Gregory Bush4-May-05 7:18
Gregory Bush4-May-05 7:18 
GeneralRe: TableLayoutPanel (Whidbey) Pin
Judah Gabriel Himango4-May-05 8:14
sponsorJudah Gabriel Himango4-May-05 8:14 
GeneralAppDomain Pin
pgoel764-May-05 6:04
pgoel764-May-05 6:04 
Hi,

I want to ask how to execute a static function in a user created application domain. I am trying to run following sample code. But it seems that the method that I am trying to execute in my created domain always executed in the default created domain (caller domain).

public void ExitProcessTest()
{
string applicationTitle = "ApplicationToBeKilled";
Assembly asm1 = Assembly.GetAssembly(typeof(OSP.Forms.ErrorBox));
AppDomainSetup ads = new AppDomainSetup();
ads.ApplicationBase = @"file:///C:\Components.NET\Testing\TestProject\bin\Debug\";
ads.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory;
ads.ApplicationName = applicationTitle;
AppDomain newappDomain = AppDomain.CreateDomain(applicationTitle, null, ads);
Assembly asm = newappDomain.Load(asm1.FullName);
Type type = asm.GetType("OSP.Forms.ErrorBox");
type.InvokeMember("ExitProcess", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[] { applicationTitle });
Thread.Sleep(15000);
}


public static void ExitProcess(string applicationTitle)
{
//It's better to close the application, otherwise, could throw many other errors
try
{
ApplicationTitle = applicationTitle;
Thread exitThread = new Thread(new ThreadStart(ApplicationExitThread));
exitThread.Name = "ExitThread";
exitThread.Start();
}
catch (Exception exc) { ShowError(exc, "Osp.Shared", null, "script_error@etb.bel.alcatel.be"); }
}

private static string ApplicationTitle;
private static void ApplicationExitThread()
{
try
{
Form f = new Form();
f.TopMost = true;
f.Size = new Size(370, 60);
f.BackColor = Color.Red;
f.FormBorderStyle = FormBorderStyle.None;
Label lbl = new Label();
lbl.BorderStyle = BorderStyle.FixedSingle;
lbl.ForeColor = Color.White;
lbl.Font = new Font("Verdana", 10, FontStyle.Bold);
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.Dock = DockStyle.Fill;
lbl.Text = "The " + ApplicationTitle + " will exit in few seconds.\nSorry for the inconvenience.";
f.Controls.Add(lbl);
f.StartPosition = FormStartPosition.CenterScreen;
f.Show();
f.TopMost = true;
f.Invalidate();
f.Update();
Thread.Sleep(1000);
for (int i = 5; i > 0; i--)
{
lbl.Text = "The " + ApplicationTitle + " will exit in " + i + " second" + (i > 1 ? "s" : "") + ".\nSorry for the inconvenient.";
lbl.Update();
Thread.Sleep(1000);//to ensure the error mail is sent!
}
//Process.GetCurrentProcess().Kill();
MessageBox.Show(AppDomain.CurrentDomain.FriendlyName);
}
catch (Exception exc) { ShowError(exc, "Osp.Shared", null, "script_error@etb.bel.alcatel.be"); }
}
Generalgetting the ONLY the Filename from FileInfo Pin
Green Fuze4-May-05 5:43
Green Fuze4-May-05 5:43 
GeneralRe: getting the ONLY the Filename from FileInfo Pin
Claudio Grazioli4-May-05 5:56
Claudio Grazioli4-May-05 5:56 
GeneralRe: getting the ONLY the Filename from FileInfo Pin
Green Fuze4-May-05 11:32
Green Fuze4-May-05 11:32 
GeneralMy EllipseLabel - wrapping text question Pin
Anonymous4-May-05 5:25
Anonymous4-May-05 5:25 
GeneralRe: My EllipseLabel - wrapping text question Pin
keith maddox4-May-05 9:56
keith maddox4-May-05 9:56 
GeneralRe: My EllipseLabel - wrapping text question Pin
ICustomTypeDescriptor4-May-05 11:00
ICustomTypeDescriptor4-May-05 11:00 
GeneralSMS from a website Pin
Trance Junkie4-May-05 4:15
Trance Junkie4-May-05 4:15 
GeneralRe: SMS from a website Pin
Judah Gabriel Himango4-May-05 8:17
sponsorJudah Gabriel Himango4-May-05 8:17 
GeneralRe: SMS from a website Pin
Shashidharreddy6-May-05 23:15
Shashidharreddy6-May-05 23:15 
GeneralICustomTypeDescriptor - implementation Pin
Anonymous4-May-05 3:45
Anonymous4-May-05 3:45 
GeneralRe: ICustomTypeDescriptor - implementation Pin
Anonymous4-May-05 4:48
Anonymous4-May-05 4:48 
GeneralRe: ICustomTypeDescriptor - implementation Pin
Anonymous4-May-05 5:10
Anonymous4-May-05 5:10 
GeneralRe: ICustomTypeDescriptor - implementation Pin
Mathew Hall4-May-05 15:48
Mathew Hall4-May-05 15:48 
Questionhow to convert text inro rtf and display the same in a richtextbox?? Pin
reachme_saurabh4-May-05 3:27
reachme_saurabh4-May-05 3:27 
AnswerRe: how to convert text inro rtf and display the same in a richtextbox?? Pin
Judah Gabriel Himango4-May-05 4:33
sponsorJudah Gabriel Himango4-May-05 4:33 
GeneralRe: how to convert text inro rtf and display the same in a richtextbox?? Pin
Anonymous4-May-05 20:18
Anonymous4-May-05 20:18 
GeneralRe: how to convert text inro rtf and display the same in a richtextbox?? Pin
Judah Gabriel Himango5-May-05 4:06
sponsorJudah Gabriel Himango5-May-05 4:06 

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.