|
NarVish,
As far as C# and VISIO are concerned, you'll want to investigate the Microsoft VSTO (Visual Studio Tools for Microsoft Office). That will get you your integration point, however, if VISIO does not support saving a document to PDF natively, you're most likely going to need to investigate purchasing a 3rd-party .NET component that can deliver that functionality for you.
My only other suggestion is to look on SourceForge.net for possible Open Source PDF projects.
|
|
|
|
|
Hi, I want to create an interface for a few applications that run with a command line interface (video codecs, to be specific). I've got it sort of working but after I run one application with it, it just stops displaying the output.
Code on the "Run App" Button: (pro_App is the name of my process component)
pro_App.StartInfo.FileName = txt_App.Text;
pro_App.StartInfo.Arguments = txt_Args.Text;
pro_App.Start();
pro_App.BeginOutputReadLine();
but_Run.Enabled = false;
Events:
private void pro_App_OutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
{
if (!String.IsNullOrEmpty(e.Data))
{
rtx_Display.AppendText(Prefix + e.Data);
Prefix = Environment.NewLine;
}
}
private void pro_App_ErrorDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
{
if (!String.IsNullOrEmpty(e.Data))
{
rtx_Display.AppendText(Prefix + "Error: " + e.Data);
Prefix = Environment.NewLine;
}
}
private void pro_App_Exited(object sender, EventArgs e)
{
but_Run.Enabled = true;
rtx_Display.AppendText(Prefix + "<Application Finished>";
Prefix = Environment.NewLine;
pro_App.CancelOutputRead();
}
Component Properties:
this.pro_ShellApp.EnableRaisingEvents = true;
this.pro_App.StartInfo.CreateNoWindow = true;
this.pro_App.StartInfo.Domain = "";
this.pro_App.StartInfo.ErrorDialog = true;
this.pro_App.StartInfo.LoadUserProfile = false;
this.pro_App.StartInfo.Password = null;
this.pro_App.StartInfo.RedirectStandardError = true;
this.pro_App.StartInfo.RedirectStandardOutput = true;
this.pro_App.StartInfo.StandardErrorEncoding = null;
this.pro_App.StartInfo.StandardOutputEncoding = null;
this.pro_App.StartInfo.UserName = "";
this.pro_App.StartInfo.UseShellExecute = false;
this.pro_App.SynchronizingObject = this
Any ideas? Thanks.
|
|
|
|
|
Hi,
I have never done it like that, I tend to use explicit threads for reading stdout and stderr.
The one thing I noticed is you don't have a pro_App.CancelErrorRead();
BTW: you do have try-catch showing the full Exception.ToString() do you?
Hope that helps.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks for your reply, how would I go about doing it your way? I haven't been using C# for very long so I've been relying mostly on tutorials and the MSDN documentation to find out how to do something new.
I do call pro_App.CancelErrorRead(); in the _Exited event to terminate the async reading but should I have it somewhere else too?
And I don't get an exception when trying to run the second app, it runs fine but just doesn't display any of the output.
|
|
|
|
|
Hi,
the code shown only included CancelOutputRead(); and no CancelErrorRead();
I tend to explicitly create a thread for reading stdout using a synchronous read in a while loop; similar for stderr. While the original thread waits for process exit (using a busy wait, i.e. a loop including a sleep(300)), waits one more second, then forces the other threads to terminate (gracefully if possible).
I started doing so back on Win98 where .NET 1.0 and 1.1 had some problems dealing with those externals streams, not sure it still is necessary nowadays.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
another thought:
AFAIK the DataReceived events get executed on another thread, so they shouldn't (probably can't) access GUI Controls. The only correct way to cope with that is by using delegates (see Control.InvokeRequired/Control.Invoke). I hope you didn't use the Control.CheckForIllegalCrossThreadCalls=false; monstrosity since that is a sure way for failure.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
Hi,
is it still not working when you have BOTH CancelRead calls present?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Nope it's still not working. The application still gets executed but it stops displaying the output after running the first app.
|
|
|
|
|
Hi,
neoflame wrote: this.pro_ShellApp.EnableRaisingEvents = true;
just noticed a possible confusion between pro_ShellApp and pro_App.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Sorry, that's just because in my project it's called pro_ShellApp but I took out the "Shell" part when I copied it here because I'm not really too sure if a console app can be called a shell app and I din't want to look too stupid :P
|
|
|
|
|
You'd better show real code, there must be a small mistake somewhere, and without the actual code people can't help you locate it.
Anyway, the below code works for me:
public void log(string s) {
lb.Items.Add(s);
lb.TopIndex=lb.Items.Count-1;
}
private void button1_Click(object sender, EventArgs e) {
p=new Process();
p.EnableRaisingEvents = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.Domain = "";
p.StartInfo.ErrorDialog = true;
p.StartInfo.LoadUserProfile = false;
p.StartInfo.Password = null;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.StandardErrorEncoding = null;
p.StartInfo.StandardOutputEncoding = null;
p.StartInfo.UserName = "";
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "ipconfig";
p.SynchronizingObject = this;
p.Exited+=p_Exited;
p.ErrorDataReceived+=p_ErrorDataReceived;
p.OutputDataReceived+=p_OutputDataReceived;
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
}
private void p_OutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) {
if (!String.IsNullOrEmpty(e.Data)) log("OUT: "+e.Data);
}
private void p_ErrorDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e) {
if (!String.IsNullOrEmpty(e.Data)) log("ERR: "+e.Data);
}
private void p_Exited(object sender, EventArgs e) {
log("END: Application Finished");
p.CancelOutputRead();
p.CancelErrorRead();
}
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thank you, that code worked perfectly I still don't know why mine wasn't working but I guess it doesn't matter now. The only thing I can't seem to get working is sending arguments to the executable. I have a text box called txt_Args and I've added p.StartInfo.Arguments = txt_Args.Text; just after where you set the FileName but it doesn't seem to work as I was expecting. I have a console app (not one that I made) that outputs help when you pass -h to it. I tried setting the path to that app and typing "-h" into the arguments field but it didn't display the help text. Yet if I open command prompt and type "theapp.exe -h" it displays the error text fine.
|
|
|
|
|
Hi,
when you add p.StartInfo.Arguments = "-all"; to my test code, it will show more output. Works fine for me.
IMO you need to take better care of small details, can't tell you exactly where though.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
What is Shortest way to move cursor to next column in DataGridView on ENTER press in C#.Net?
|
|
|
|
|
Convert it to a TAB key
I are troll
|
|
|
|
|
Hello Experts....
I am displaying my crystal report by coding on print button.now i want print it without using crystal report design print option i.e.by coding.....Is there any code for same.
Please help me.
|
|
|
|
|
Use Google
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Hi,
I draw a Ball in a panel and I want it to move towards the position of the mouse that was clicked.I want to use a thread for the ball's path.so anybody can introduce any source or help?not that I did'nt try,I did (alot).but result was'nt what I wanted!
Thanks
|
|
|
|
|
|
I want to add SP2 of Window-XP as prerequisite in my Window application Setup. How can I do this?
Thanks in advance.
|
|
|
|
|
What kind of setup are you using? NSIS? MSI? other?
|
|
|
|
|
|
Hello friends,
Nice to be in CodeProject again! Can somebody tell me what exactly will be the piece of code for killing an active process? ex. notepad.exe.
Cheers,
Rajdeep.NET
|
|
|
|
|
Why don't you google? Or read the documentation?
जय हिंद
|
|
|
|