I am trying to Send Data to a running windows form application written in C# from my asp.net Webpage. The Problem that the Application is not starting when I call it from the webpage , but if I try to run it from command Line.
This is the Part of Code launching my application in asp.net
protected void Page_Load(object sender, EventArgs e)
{
// ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:connectSocketServer(); ", true);
SecureString sc = new SecureString();
string Source = "*****";
foreach (char c in Source.ToCharArray())
{
sc.AppendChar(c);
}
ProcessStartInfo i = new ProcessStartInfo(@"C:\******\myapp.exe", "test");
i.UserName = "******";
i.UseShellExecute = false;
i.Password = sc;
i.Verb = "runas";
Process p = new Process();
p.StartInfo = i;
p.Start();
}
and this is the Code from my application
static System.Threading.Mutex mutex = new Mutex(true, "{8F6F0AC4-B9A1-45fd-A8CF-72F04E6BDE8F}");
[STAThread]
static void Main(params string[] Arguments)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 mf = new Form1();
if (mutex.WaitOne(TimeSpan.Zero, true))
{
Application.Run(mf);
mutex.ReleaseMutex();
}
else
{
MessageBox.Show("only one instance at a time");
mf.SendData(Arguments);
}
}
and in the form there is a public function Called SendData that will process the Data...
So if I run it from cmd line and Pass arguments , SendData will be excuted , but from webpage not working...
Note : I remove the username and password information the application apears on task manager under IWAP user but form don't show.