473,651 Members | 3,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Printing problem using - System.Diagnost ics.ProcessStar tInfo s

Hi Mike

I have changed the code using Server.MapPath but to no avail.
Prints the Adobe PDF document to the default local printer
(I am running this localhost). I Have not run it on the server yet.

What confuses me is

1. All the documents to be printed are in the same directory -
The application directory - so the authorities to the objects
should all be the same. All objects have the same Access
properties.If it can find the PDF document then why can't
it find the .doc and .xls documents.
2. Each of the applications starts up. Adobe, Excel, Word.
I can see the application start in the task manager.
This suggests that both Excel and Word are trying to
perform the required action but failing;
3. The catch throws an Access Denied exception in response
to the error.
(The catch does not throw an exception if there is an existing
instance of the Word or Excel application running. The page
just hangs and no exception is thrown).
I have a small piece of code to forceably kill the process if
it does not end itself. In both the Excel and WORK instances
the code throws an exception

No process is associated with this object

try
{
if (myProcess.HasE xited == false)
{
myProcess.Kill( );
}
}
catch (Win32Exception ex)
{
label1.Text = label1.Text + "<br><br><b r>" + "Cannot Kill Process :
Error Code = " +
ex.ErrorCode + "<br>" + "Base Exception Is " +
ex.GetBaseExcep tion() + "<br>" + "Inner Exception Is " +
ex.InnerExcepti on + "<br><br><b r>";
}
Surely if the process has started then there must be a process
associated with the process object !!!!

I am confused.

best regards

Iain
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++

Code
-------

try
{
myProcess.Start Info.FileName = Server.MapPath (PFileName);
myProcess.Start Info.Verb = "Print";
myProcess.Start Info.CreateNoWi ndow = true;
myProcess.Start ();
myProcess.WaitF orExit(20000);
}
catch (Win32Exception ex)
{
if(ex.NativeErr orCode == ERROR_FILE_NOT_ FOUND)
{
label1.Text = label1.Text + "<br><br><b r>" + "Path Error : " +
ex.Message + "<br><br><b r>";
}
else
if (ex.NativeError Code == ERROR_ACCESS_DE NIED)
{
label1.Text = label1.Text + "<br><br><b r>" + "Permission Error : "
+ ex.Message + "<br><br><b r>";
}
else
{
label1.Text = label1.Text + "<br><br><b r>" + "Unknown Error : " +
ex.Message + "<br><br><b r>";
}
}
Jun 27 '08 #1
2 4826
Outside of the web application with the word and xls files where the website
tries to open them, can you successfully open them from windows explorer?
Also try printing from explorer. I'm hoping this will provide a clue to what
is going on with office files.

"Iain Wilson" wrote:
Hi Mike

I have changed the code using Server.MapPath but to no avail.
Prints the Adobe PDF document to the default local printer
(I am running this localhost). I Have not run it on the server yet.

What confuses me is

1. All the documents to be printed are in the same directory -
The application directory - so the authorities to the objects
should all be the same. All objects have the same Access
properties.If it can find the PDF document then why can't
it find the .doc and .xls documents.
2. Each of the applications starts up. Adobe, Excel, Word.
I can see the application start in the task manager.
This suggests that both Excel and Word are trying to
perform the required action but failing;
3. The catch throws an Access Denied exception in response
to the error.
(The catch does not throw an exception if there is an existing
instance of the Word or Excel application running. The page
just hangs and no exception is thrown).
I have a small piece of code to forceably kill the process if
it does not end itself. In both the Excel and WORK instances
the code throws an exception

No process is associated with this object

try
{
if (myProcess.HasE xited == false)
{
myProcess.Kill( );
}
}
catch (Win32Exception ex)
{
label1.Text = label1.Text + "<br><br><b r>" + "Cannot Kill Process :
Error Code = " +
ex.ErrorCode + "<br>" + "Base Exception Is " +
ex.GetBaseExcep tion() + "<br>" + "Inner Exception Is " +
ex.InnerExcepti on + "<br><br><b r>";
}
Surely if the process has started then there must be a process
associated with the process object !!!!

I am confused.

best regards

Iain
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++

Code
-------

try
{
myProcess.Start Info.FileName = Server.MapPath (PFileName);
myProcess.Start Info.Verb = "Print";
myProcess.Start Info.CreateNoWi ndow = true;
myProcess.Start ();
myProcess.WaitF orExit(20000);
}
catch (Win32Exception ex)
{
if(ex.NativeErr orCode == ERROR_FILE_NOT_ FOUND)
{
label1.Text = label1.Text + "<br><br><b r>" + "Path Error : " +
ex.Message + "<br><br><b r>";
}
else
if (ex.NativeError Code == ERROR_ACCESS_DE NIED)
{
label1.Text = label1.Text + "<br><br><b r>" + "Permission Error : "
+ ex.Message + "<br><br><b r>";
}
else
{
label1.Text = label1.Text + "<br><br><b r>" + "Unknown Error : " +
ex.Message + "<br><br><b r>";
}
}
Jun 27 '08 #2
From Windows explorer I can

Open both the Excel and Word documents (All looks well) and Right
click and print both documents.

When I right click and select print

The appropriate application opens up
The document is sent to the printer
The application closes down
The document is printed.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1196
by: Barry Munro | last post by:
Hi, I'm using the following code to print documents from the file system but i'm encountering strange behaviour. If I print one document it works ok but if i say loop round a list of files and print them they start coming out in the wrong order, some of the documents are printed multiple times and others are not printed at all. I think it might be the invoked application, word, outlook, acrobat etc, getting in a mess when it has to...
0
3292
by: Daniel Reber | last post by:
I am trying to start a process from a windows service but when the process starts the command window that the process runs in never shows. Is this because I am calling it from a windows service? Is there something else that I need to do? Here is my code: System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
1
6053
by: Morten | last post by:
Hi! Does anyone know why the code below always returns an "access is denied" error? private void Page_Load(object sender, System.EventArgs e) { System.Diagnostics.Process meProc = System.Diagnostics.Process.Start ("cmd.exe", " /c echo y| CACLS C:\\Temp /E /T /G test:F");
2
10447
by: Eranga | last post by:
I have a windows application in C# which has the following method public void InitiateSession(string server,string userName, string passWd ) { //To start the command System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); psi.FileName = @"C:\WINDOWS\system32\cmd.exe"; // Path for the cmd prompt psi.Arguments = @"c\ net use \\servername\IPC$ /USER:domain\user
5
4024
by: David Conorozzo | last post by:
I am able to create new sources using CreateEventSource. I can call GetEventLogs, I can delete sources, I can see if sources exist BUT, as soon as I try a "WriteEntry", I get an exception: {System.InvalidOperationException} : {System.InvalidOperationException} HelpLink: Nothing InnerException: {System.ComponentModel.Win32Exception}
1
3041
by: Heiko Besemann | last post by:
Dear group, I created an aspx page using System.Diagnostics.Process() to launch "tracert" from shell and redirect output to Response.Output which prints it as text/plain into my browsers window. Now that works fine so far. My problem is that while tracert process is running and ASP ..NET is putting data into the pages output stream, my webapplication is locked until tracert process exits. How can I stop locking my application and be...
1
1612
by: Jiho Han | last post by:
I am wondering whether asp.net applications can write trace information using the System.Diagnostics.Trace class, and also whether in web.config, the <system.diagnostics> element and its sub elements have effect. Trace.axd is good but not perfect. I would like to use a separate file for writing trace information in addition to Trace.axd. Also, what happens when you call Trace.Close which has a set of listeners including a text file...
0
1105
by: Speech Lover | last post by:
I am trying to find a sample from the Internet about invoking a command line from .NET 2.0 by using System.Diagnostics.Process with Domain, UserName and Password specified? All samples I found so far are without UserName and Password specified. thanks, Speech Lover
1
2546
by: anup2331 | last post by:
Hi there, I want to execute the "C:\Program Files\ABCD\Metro1.1\Converter\mysoftware.exe D:\\Test\SOMEFILE.ADT C:\Program Files\ABCD\Metro1.1\CSV\somefile.csv 0" But it gives me an error. Therefore I want to run two commands, one for setting the path variables and the other for executing this command "Converter\mysoftware.exe D:\\Test\SOMEFILE.ADT CSV\somefile.csv 0" Can somebody help me out.
0
8361
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.