473,503 Members | 6,587 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't "Quick View" second instance of System.Diagnostics.Process object

I have a requirement to initiate more than one instance of an
application using the filenames. (the example below will start two
instances of MS Word).

My problem is that I need to kill each instance individually, but this
does not appear possible using the Process object. When I run the
example below the process object "p" can be viewed using Quick Watch
however process object p2 is displayed as undefined, with the added
affect of not being able to kill instance p2.

-Code----------------------------------------------
ProcessStartInfo startInfo = new ProcessStartInfo("a.doc");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process p = Process.Start(startInfo);
......
ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc");
startInfo2.WindowStyle = ProcessWindowStyle.Minimized;
Process p2 = Process.Start(startInfo2);
....
p.Kill();
....
p2.Kill();
-End Code----------------------------------------------
Does anyone have an explanation for this?
Is there another way of doing it?

Regards
Gavin
Nov 17 '05 #1
6 2163
Is Word opening b.doc using the same process as the first? That would explain it.

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...
I have a requirement to initiate more than one instance of an
application using the filenames. (the example below will start two
instances of MS Word).

My problem is that I need to kill each instance individually, but this
does not appear possible using the Process object. When I run the
example below the process object "p" can be viewed using Quick Watch
however process object p2 is displayed as undefined, with the added
affect of not being able to kill instance p2.

-Code----------------------------------------------
ProcessStartInfo startInfo = new ProcessStartInfo("a.doc");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process p = Process.Start(startInfo);
.....
ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc");
startInfo2.WindowStyle = ProcessWindowStyle.Minimized;
Process p2 = Process.Start(startInfo2);
...
p.Kill();
...
p2.Kill();
-End Code----------------------------------------------
Does anyone have an explanation for this?
Is there another way of doing it?

Regards
Gavin

Nov 17 '05 #2
Thanks for your response Dave. I tested it using a text document
opening it in notepad and it works as I would have hoped, so you
appear to be correct in that it is opening Word in the same process.

That explains the problem a little further, however my problem still
remains...I need to be able to kill off one of the word documents
without killing off the other. Any ideas?

Thanks
Gavin

"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<OE**************@TK2MSFTNGP12.phx.gbl>...
Is Word opening b.doc using the same process as the first? That would explain it.

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...
I have a requirement to initiate more than one instance of an
application using the filenames. (the example below will start two
instances of MS Word).

My problem is that I need to kill each instance individually, but this
does not appear possible using the Process object. When I run the
example below the process object "p" can be viewed using Quick Watch
however process object p2 is displayed as undefined, with the added
affect of not being able to kill instance p2.

-Code----------------------------------------------
ProcessStartInfo startInfo = new ProcessStartInfo("a.doc");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process p = Process.Start(startInfo);
.....
ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc");
startInfo2.WindowStyle = ProcessWindowStyle.Minimized;
Process p2 = Process.Start(startInfo2);
...
p.Kill();
...
p2.Kill();
-End Code----------------------------------------------
Does anyone have an explanation for this?
Is there another way of doing it?

Regards
Gavin

Nov 17 '05 #3
Yep :)

Using Word automation you can access the opened documents and do what you will with them. There are plenty resources out there
(just search MSDN or groups.google.com) about automating Office applications.

You need to reference an Interop wrapped Word assembly. You can do this by opening the project references dialog in VS.NET, hitting
the COM tab and browsing for Microsoft Word. I don't believe Office supplies any Primary Interop assembly for Word at this time,
but if I'm wrong it would be under the .NET tab, or in a folder somewhere in the office heirarchy of folders. For now, just use COM
tab and select Word as I suggested. If it's not in the list, simply browse to the executable and add it. VS.NET will use a tool to
wrap the assembly for you.

Here are examples of using automation in C#:

using Word;
...
Word.Application app =
Activator.CreateInstance(Type.GetTypeFromProgID("W ord.Application", false)) as Word.Application;

This code places the instance of Word in the ROT (running object table). Now, when you close your app, Word is closed too.
Here's another way of accessing Word (this way won't link Word to your process):

Word.Application app =
System.Runtime.InteropServices.Marshal.GetActiveOb ject("Word.Application") as Word.Application;

This code retrieves an instance of Word from the ROT, but does not "link" it to the running process. When your app is closed, Word
is not.
If "app" = null then run the following line, and then run the above line once more (again testing for null!):

System.Diagnostics.Process.Start("Word");

GL

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...
Thanks for your response Dave. I tested it using a text document
opening it in notepad and it works as I would have hoped, so you
appear to be correct in that it is opening Word in the same process.

That explains the problem a little further, however my problem still
remains...I need to be able to kill off one of the word documents
without killing off the other. Any ideas?

Thanks
Gavin

"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<OE**************@TK2MSFTNGP12.phx.gbl>...
Is Word opening b.doc using the same process as the first? That would explain it.

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...
>I have a requirement to initiate more than one instance of an
> application using the filenames. (the example below will start two
> instances of MS Word).
>
> My problem is that I need to kill each instance individually, but this
> does not appear possible using the Process object. When I run the
> example below the process object "p" can be viewed using Quick Watch
> however process object p2 is displayed as undefined, with the added
> affect of not being able to kill instance p2.
>
> -Code----------------------------------------------
> ProcessStartInfo startInfo = new ProcessStartInfo("a.doc");
> startInfo.WindowStyle = ProcessWindowStyle.Minimized;
> Process p = Process.Start(startInfo);
> .....
> ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc");
> startInfo2.WindowStyle = ProcessWindowStyle.Minimized;
> Process p2 = Process.Start(startInfo2);
> ...
> p.Kill();
> ...
> p2.Kill();
> -End Code----------------------------------------------
>
>
> Does anyone have an explanation for this?
> Is there another way of doing it?
>
> Regards
> Gavin

Nov 17 '05 #4
Thanks Dave...

I am familiar with the Word Object Library from VB6 days and wanted to
avoid it for a number of reasons....

1. The application we are developing will launch the windows default
application depending on the extension of file being opened, e.g. txt
files will launch notepad. In the case of .doc files it will open
Word, however we want this as flexible as possible so there may be a
situation where .doc files launch something other than Word.
2. Possible version conflicts, between version of word installed on
client machine and version of Microsoft Word Object Library that the
application has a dependency on.

It may be the case that we need to cater specifically for Word (and
Excel) due to the way it manages multiple documents within the one
process; this being the case the Word object library may be the way to
go, so I have managed to take your suggestion and build a prototype
and will bring it to the table as a squareish peg for the round hole.

Many thanks for your time and contribution. If you have any further
suggestions they would be much appreciated.

Regards
Gavin

"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<Or**************@TK2MSFTNGP10.phx.gbl>...
Yep :)

Using Word automation you can access the opened documents and do what you will with them. There are plenty resources out there
(just search MSDN or groups.google.com) about automating Office applications.

You need to reference an Interop wrapped Word assembly. You can do this by opening the project references dialog in VS.NET, hitting
the COM tab and browsing for Microsoft Word. I don't believe Office supplies any Primary Interop assembly for Word at this time,
but if I'm wrong it would be under the .NET tab, or in a folder somewhere in the office heirarchy of folders. For now, just use COM
tab and select Word as I suggested. If it's not in the list, simply browse to the executable and add it. VS.NET will use a tool to
wrap the assembly for you.

Here are examples of using automation in C#:

using Word;
...
Word.Application app =
Activator.CreateInstance(Type.GetTypeFromProgID("W ord.Application", false)) as Word.Application;

This code places the instance of Word in the ROT (running object table). Now, when you close your app, Word is closed too.
Here's another way of accessing Word (this way won't link Word to your process):

Word.Application app =
System.Runtime.InteropServices.Marshal.GetActiveOb ject("Word.Application") as Word.Application;

This code retrieves an instance of Word from the ROT, but does not "link" it to the running process. When your app is closed, Word
is not.
If "app" = null then run the following line, and then run the above line once more (again testing for null!):

System.Diagnostics.Process.Start("Word");

GL

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...
Thanks for your response Dave. I tested it using a text document
opening it in notepad and it works as I would have hoped, so you
appear to be correct in that it is opening Word in the same process.

That explains the problem a little further, however my problem still
remains...I need to be able to kill off one of the word documents
without killing off the other. Any ideas?

Thanks
Gavin

"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<OE**************@TK2MSFTNGP12.phx.gbl>...
Is Word opening b.doc using the same process as the first? That would explain it.

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...
>I have a requirement to initiate more than one instance of an
> application using the filenames. (the example below will start two
> instances of MS Word).
>
> My problem is that I need to kill each instance individually, but this
> does not appear possible using the Process object. When I run the
> example below the process object "p" can be viewed using Quick Watch
> however process object p2 is displayed as undefined, with the added
> affect of not being able to kill instance p2.
>
> -Code----------------------------------------------
> ProcessStartInfo startInfo = new ProcessStartInfo("a.doc");
> startInfo.WindowStyle = ProcessWindowStyle.Minimized;
> Process p = Process.Start(startInfo);
> .....
> ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc");
> startInfo2.WindowStyle = ProcessWindowStyle.Minimized;
> Process p2 = Process.Start(startInfo2);
> ...
> p.Kill();
> ...
> p2.Kill();
> -End Code----------------------------------------------
>
>
> Does anyone have an explanation for this?
> Is there another way of doing it?
>
> Regards
> Gavin

Nov 17 '05 #5
Thanks Dave...

I am familiar with the Word Object Library from VB6 days and wanted to
avoid it for a number of reasons....

1. The application we are developing will launch the windows default
application depending on the extension of file being opened, e.g. txt
files will launch notepad. In the case of .doc files it will open
Word, however we want this as flexible as possible so there may be a
situation where .doc files launch something other than Word.
2. Possible version conflicts, between version of word installed on
client machine and version of Microsoft Word Object Library that the
application has a dependency on.

It may be the case that we need to cater specifically for Word (and
Excel) due to the way it manages multiple documents within the one
process; this being the case the Word object library may be the way to
go, so I have managed to take your suggestion and build a prototype
and will bring it to the table as a squareish peg for the round hole.

Many thanks for your time and contribution. If you have any further
suggestions they would be much appreciated.

Regards
Gavin

"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<Or**************@TK2MSFTNGP10.phx.gbl>...
Yep :)

Using Word automation you can access the opened documents and do what you will with them. There are plenty resources out there
(just search MSDN or groups.google.com) about automating Office applications.

You need to reference an Interop wrapped Word assembly. You can do this by opening the project references dialog in VS.NET, hitting
the COM tab and browsing for Microsoft Word. I don't believe Office supplies any Primary Interop assembly for Word at this time,
but if I'm wrong it would be under the .NET tab, or in a folder somewhere in the office heirarchy of folders. For now, just use COM
tab and select Word as I suggested. If it's not in the list, simply browse to the executable and add it. VS.NET will use a tool to
wrap the assembly for you.

Here are examples of using automation in C#:

using Word;
...
Word.Application app =
Activator.CreateInstance(Type.GetTypeFromProgID("W ord.Application", false)) as Word.Application;

This code places the instance of Word in the ROT (running object table). Now, when you close your app, Word is closed too.
Here's another way of accessing Word (this way won't link Word to your process):

Word.Application app =
System.Runtime.InteropServices.Marshal.GetActiveOb ject("Word.Application") as Word.Application;

This code retrieves an instance of Word from the ROT, but does not "link" it to the running process. When your app is closed, Word
is not.
If "app" = null then run the following line, and then run the above line once more (again testing for null!):

System.Diagnostics.Process.Start("Word");

GL

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...
Thanks for your response Dave. I tested it using a text document
opening it in notepad and it works as I would have hoped, so you
appear to be correct in that it is opening Word in the same process.

That explains the problem a little further, however my problem still
remains...I need to be able to kill off one of the word documents
without killing off the other. Any ideas?

Thanks
Gavin

"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<OE**************@TK2MSFTNGP12.phx.gbl>...
Is Word opening b.doc using the same process as the first? That would explain it.

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...
>I have a requirement to initiate more than one instance of an
> application using the filenames. (the example below will start two
> instances of MS Word).
>
> My problem is that I need to kill each instance individually, but this
> does not appear possible using the Process object. When I run the
> example below the process object "p" can be viewed using Quick Watch
> however process object p2 is displayed as undefined, with the added
> affect of not being able to kill instance p2.
>
> -Code----------------------------------------------
> ProcessStartInfo startInfo = new ProcessStartInfo("a.doc");
> startInfo.WindowStyle = ProcessWindowStyle.Minimized;
> Process p = Process.Start(startInfo);
> .....
> ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc");
> startInfo2.WindowStyle = ProcessWindowStyle.Minimized;
> Process p2 = Process.Start(startInfo2);
> ...
> p.Kill();
> ...
> p2.Kill();
> -End Code----------------------------------------------
>
>
> Does anyone have an explanation for this?
> Is there another way of doing it?
>
> Regards
> Gavin

Nov 17 '05 #6
> It may be the case that we need to cater specifically for Word (and
Excel) due to the way it manages multiple documents within the one
process
Unfortunately, I believe you will have to cater to those apps. If your using the extension mapping, you're program will have to be
aware of MDI apps (as you've mentioned above).

I'm glad I could help.

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... Thanks Dave...

I am familiar with the Word Object Library from VB6 days and wanted to
avoid it for a number of reasons....

1. The application we are developing will launch the windows default
application depending on the extension of file being opened, e.g. txt
files will launch notepad. In the case of .doc files it will open
Word, however we want this as flexible as possible so there may be a
situation where .doc files launch something other than Word.
2. Possible version conflicts, between version of word installed on
client machine and version of Microsoft Word Object Library that the
application has a dependency on.

It may be the case that we need to cater specifically for Word (and
Excel) due to the way it manages multiple documents within the one
process; this being the case the Word object library may be the way to
go, so I have managed to take your suggestion and build a prototype
and will bring it to the table as a squareish peg for the round hole.

Many thanks for your time and contribution. If you have any further
suggestions they would be much appreciated.

Regards
Gavin

"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<Or**************@TK2MSFTNGP10.phx.gbl>...
Yep :)

Using Word automation you can access the opened documents and do what you will with them. There are plenty resources out there
(just search MSDN or groups.google.com) about automating Office applications.

You need to reference an Interop wrapped Word assembly. You can do this by opening the project references dialog in VS.NET,
hitting
the COM tab and browsing for Microsoft Word. I don't believe Office supplies any Primary Interop assembly for Word at this time,
but if I'm wrong it would be under the .NET tab, or in a folder somewhere in the office heirarchy of folders. For now, just use
COM
tab and select Word as I suggested. If it's not in the list, simply browse to the executable and add it. VS.NET will use a tool
to
wrap the assembly for you.

Here are examples of using automation in C#:

using Word;
...
Word.Application app =
Activator.CreateInstance(Type.GetTypeFromProgID("W ord.Application", false)) as Word.Application;

This code places the instance of Word in the ROT (running object table). Now, when you close your app, Word is closed too.
Here's another way of accessing Word (this way won't link Word to your process):

Word.Application app =
System.Runtime.InteropServices.Marshal.GetActiveOb ject("Word.Application") as Word.Application;

This code retrieves an instance of Word from the ROT, but does not "link" it to the running process. When your app is closed,
Word
is not.
If "app" = null then run the following line, and then run the above line once more (again testing for null!):

System.Diagnostics.Process.Start("Word");

GL

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...
> Thanks for your response Dave. I tested it using a text document
> opening it in notepad and it works as I would have hoped, so you
> appear to be correct in that it is opening Word in the same process.
>
> That explains the problem a little further, however my problem still
> remains...I need to be able to kill off one of the word documents
> without killing off the other. Any ideas?
>
> Thanks
> Gavin
>
> "Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<OE**************@TK2MSFTNGP12.phx.gbl>...
>> Is Word opening b.doc using the same process as the first? That would explain it.
>>
>> --
>> Dave Sexton
>> dave@www..jwaonline..com
>> -----------------------------------------------------------------------
>> <gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...
>> >I have a requirement to initiate more than one instance of an
>> > application using the filenames. (the example below will start two
>> > instances of MS Word).
>> >
>> > My problem is that I need to kill each instance individually, but this
>> > does not appear possible using the Process object. When I run the
>> > example below the process object "p" can be viewed using Quick Watch
>> > however process object p2 is displayed as undefined, with the added
>> > affect of not being able to kill instance p2.
>> >
>> > -Code----------------------------------------------
>> > ProcessStartInfo startInfo = new ProcessStartInfo("a.doc");
>> > startInfo.WindowStyle = ProcessWindowStyle.Minimized;
>> > Process p = Process.Start(startInfo);
>> > .....
>> > ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc");
>> > startInfo2.WindowStyle = ProcessWindowStyle.Minimized;
>> > Process p2 = Process.Start(startInfo2);
>> > ...
>> > p.Kill();
>> > ...
>> > p2.Kill();
>> > -End Code----------------------------------------------
>> >
>> >
>> > Does anyone have an explanation for this?
>> > Is there another way of doing it?
>> >
>> > Regards
>> > Gavin

Nov 17 '05 #7

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

Similar topics

3
10801
by: imani_technology_spam | last post by:
We need to present hierarchical data on a web page, the same way the tree view shows files in Windows Explorer. Here's the catch: that tree view needs to be bound to a SQL Server database. How...
18
2520
by: Lorem Ipsum | last post by:
interesting! I just found a page in which Explorer's View Source does nothing! How did they do that?
1
1339
by: jloxsom | last post by:
Hi all... New user new to VC++. I've used the AppWizard to create an SDI with the CFormclass. The "View" file is a dialog. I want to create a few EditBoxes, associate member variables to...
1
1595
by: dw | last post by:
Hello, all. I have a site that works fine when viewed in IE apart from the project in Visual Studio .NET 2003. However, when I right-click and do View in Browser, it tries to open it in the wrong...
1
1572
by: bnlockwood | last post by:
I'm looking to have the same kind of feature gmail does in that it is able to view pdf files as html. I want to be able to have a PDF file, have a view as html button but not have 2 files one html...
10
1740
by: Wildemar Wildenburger | last post by:
Hi there :) I don't know how else to call what I'm currently implementing: An object that behaves like a list but doesn't store it's own items but rather pulls them from a larger list (if they...
1
1855
by: RSH | last post by:
Hi, I have a user created control that has quite a bit of codebehind code. I have one link in the HTML page code that I need to insert the current URL in. I have tried several scenerios but...
7
5870
by: alessandro menchini | last post by:
Hello, First of all: i apologize for my english...i'm still learning... If i create a view it seems that DB2 manage this view like an updateable view. But I need to create a view "read only",...
2
2032
by: Phaiz | last post by:
Not sure if you'd need an activex control but I'm looking for a script to change the folder view to "Classic View" within IE. I have an iframe that loads the users My Documents folder and would...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7264
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,...
0
7316
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...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3160
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...
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.