none
How to run windows form application from class library in c#???

    Question

  • Hello all,

    i want to run windows application from the class library in c#.

    i have tried below code in my project.

     Process p = new Process();
                            p.StartInfo.UseShellExecute = false;
                            p.StartInfo.CreateNoWindow = false;
                            p.StartInfo.RedirectStandardOutput = true;
                            p.StartInfo.FileName = @"C:\QueuePublishConsole\QueuePublishConsole\bin\Debug\QueuePublishConsole.exe";
                            p.StartInfo.RedirectStandardInput = true;
                            // then you will have
                            p.Start();
    
                            // then add
    
                            StreamWriter sw = p.StandardInput;
                            sw.WriteLine("1"); // you might also try with different string here and more characters
                            sw.Close();
    

    but it is not working and also it is not giving any error.

    so what modification i have to do in my code???

    Regards

    Kartik

    Monday, March 12, 2012 7:04 AM

Answers

  • Hi Kartik,

    you have to call this Class Library from other C# Application.

    you did not mentioned which type of class do you created.

    Normal Class or Static Class.

    I think this Application File is not in Proper Folder that's why this process not run.

    Regards

    Kayden

    Monday, March 12, 2012 6:17 PM

All replies

  • Hi

    This code has no issues,

    Is the path you mentioned points to winform application?


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".

    Monday, March 12, 2012 8:48 AM
  • Hello kris

    Thanks for reply,

    yes, this path point to winform application but it is not run. i am not able to see windows form when class library is invoked.

    so what modification should i have to do in above code...???

    Kartik

    Monday, March 12, 2012 8:53 AM
  • Hi Kartik,

    you have to call this Class Library from other C# Application.

    you did not mentioned which type of class do you created.

    Normal Class or Static Class.

    I think this Application File is not in Proper Folder that's why this process not run.

    Regards

    Kayden

    Monday, March 12, 2012 6:17 PM
  • Hello Smith,

    Thanks for your reply, the type of class is "normal" and the folder in which my windows application exist is proper because i already have run console application from the same class library and it is successfully run.

    actually this class library is a plugin of CRM 4.0 which invoked when any opportunity is closed as won.and from that i want to run windows application. i had some trouble before to run console application from my plugin, if you want to see that then please check my thread.

    so what i have to do with windows application???

    Regards

    kartik.

    Tuesday, March 13, 2012 9:05 AM