Click here to Skip to main content
15,921,840 members
Home / Discussions / C#
   

C#

 
GeneralRe: play movi file by c# Pin
MoustafaS5-May-05 0:55
MoustafaS5-May-05 0:55 
Generalmultiple same taskbarnotifier in C# Pin
dwark1064-May-05 14:57
dwark1064-May-05 14:57 
GeneralAdding HTML Files to Solution Pin
C.S.4-May-05 14:38
C.S.4-May-05 14:38 
GeneralHelp with class hierarchy Pin
ICustomTypeDescriptor4-May-05 14:07
ICustomTypeDescriptor4-May-05 14:07 
GeneralRe: Help with class hierarchy Pin
Marc Clifton4-May-05 14:52
mvaMarc Clifton4-May-05 14:52 
GeneralRe: Help with class hierarchy Pin
Claudio Grazioli4-May-05 21:39
Claudio Grazioli4-May-05 21:39 
GeneralRe: Help with class hierarchy Pin
ICustomTypeDescriptor4-May-05 22:39
ICustomTypeDescriptor4-May-05 22:39 
GeneralStop Word Application programmatically Pin
rikpak4-May-05 12:54
rikpak4-May-05 12:54 
GeneralRe: Stop Word Application programmatically Pin
Fernando Soto4-May-05 14:51
Fernando Soto4-May-05 14:51 
Generaldropdown controls Pin
leesamanth4-May-05 11:26
leesamanth4-May-05 11:26 
GeneralRe: dropdown controls Pin
MoustafaS4-May-05 13:01
MoustafaS4-May-05 13:01 
GeneralRe: dropdown controls Pin
leesamanth4-May-05 19:26
leesamanth4-May-05 19:26 
GeneralRe: dropdown controls Pin
MoustafaS5-May-05 1:21
MoustafaS5-May-05 1:21 
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 

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.