Really dumb question: How do I call one .EXE from another, passing parms into the constructor? 
Author Message
 Really dumb question: How do I call one .EXE from another, passing parms into the constructor?

Newbie question:  I wrote and compile 2 .EXEs which display windows forms.
From the VB.NET program I'm trying to call another EXE and pass parameters
to its constructor.  I'm trying to get this to work using AppDomain and
CreateInstance.  And it works ok w/o parameters.  But I can't get the syntax
right to pass parms.  How do I do this?  Is there an easier way, besides
AppDomain and CreateInstance?

Thank you in advance.



Sat, 17 Jul 2004 11:13:29 GMT  
 Really dumb question: How do I call one .EXE from another, passing parms into the constructor?
The only dumb question is the one that is unasked. C# makes a lot of this
type of stuff easier, although VB.NET is more flexible. Let's assume a non
GUI (or Console) app for starters.

NOTE: This assumes you are using the RTM, as this will not work with some
betas:

Module Module1
  Sub Main(ByVal strArgs() As String)
    Dim intCounter As Integer
    For intCounter = 0 To UBound(strArgs)
       Console.WriteLine(intCounter & ". " & strArgs(intCounter))
    Next
    Console.Read()
  End Sub
End Module

Now, you can call this app (I called it Test App), like this:

testApp.exe I can now accept parameters on start.

The Main() here is the starting point of the app, and can accept parameters.

The other way (not preferred):
-------------------------------
Add a reference to the Microsoft.Visual.Basic DLL and use the namespace. You
can then access the Command object (for command line arguments) and parse it
out. The parsing will add additional overhead, but it will feel familiar.
Here is the code:

Module Module1
  Sub Main()
    'NOTE: Split(x," ") and Split(x) are the same.
    Dim strArgs() As String = Split(Microsoft.VisualBasic.Command)
    Dim intCounter As Integer
    For intCounter = 0 To UBound(strArgs)
      Console.WriteLine(intCounter & ". " & strArgs(intCounter))
    Next
    Console.Read()
  End Sub
End Module

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

****************************************************************************
****
Think outside the box!
****************************************************************************
****


Quote:

> Newbie question:  I wrote and compile 2 .EXEs which display windows forms.
> From the VB.NET program I'm trying to call another EXE and pass parameters
> to its constructor.  I'm trying to get this to work using AppDomain and
> CreateInstance.  And it works ok w/o parameters.  But I can't get the
syntax
> right to pass parms.  How do I do this?  Is there an easier way, besides
> AppDomain and CreateInstance?

> Thank you in advance.



Sat, 17 Jul 2004 11:44:05 GMT  
 Really dumb question: How do I call one .EXE from another, passing parms into the constructor?
Why not using DLL's?
It's much easier to pass parameters to DLL's

Peter

On Mon, 28 Jan 2002 22:13:29 -0500, "Jose Arcadio Buendia"

Quote:

>Newbie question:  I wrote and compile 2 .EXEs which display windows forms.
>From the VB.NET program I'm trying to call another EXE and pass parameters
>to its constructor.  I'm trying to get this to work using AppDomain and
>CreateInstance.  And it works ok w/o parameters.  But I can't get the syntax
>right to pass parms.  How do I do this?  Is there an easier way, besides
>AppDomain and CreateInstance?

>Thank you in advance.



Sat, 17 Jul 2004 15:41:14 GMT  
 Really dumb question: How do I call one .EXE from another, passing parms into the constructor?



Quote:
> Why not using DLL's?
> It's much easier to pass parameters to DLL's

> Peter

The two EXEs display forms...Can't use DLLs

This the code:
''''''''' This works: starts at default form, but no parms passed....

Dim CurrentDomain As AppDomain = AppDomain.CurrentDomain()

 CurrentDomain.CreateInstance("SiteSurveyHome2C",
"SiteSurveyHome2C.frmMatReqList")

'''''''''' Try to pas parms...This doesn't work  - I get a compile (syntax)
error on the CreateInstance ... objParms()

Dim objParms() As Object

objParms(0) = CType(24, Object)

Dim CurrentDomain As AppDomain = AppDomain.CurrentDomain()

''''' Error on the following line objParms()

CurrentDomain.CreateInstance("SiteSurveyHome2C",
"SiteSurveyHome2C.frmMatReqList", True,
Reflection.BindingFlags.CreateInstance, Nothing, objParms(), Nothing,
Nothing, , )

Any ideas?  Thanks



Sun, 18 Jul 2004 02:00:06 GMT  
 Really dumb question: How do I call one .EXE from another, passing parms into the constructor?

Quote:
> The two EXEs display forms...Can't use DLLs

Sure you can! Not sure who told you that it is not true. Even in VB6 you
could display forms through DLLs.

If this were the case, I have spent the last two months on my current
project all for nothing! ;-) But fortunately it is not.

Cal



Sun, 18 Jul 2004 02:10:12 GMT  
 Really dumb question: How do I call one .EXE from another, passing parms into the constructor?
O sure you can display a form in a dll, a form in VB.Net is now also a
class.

On Tue, 29 Jan 2002 13:00:06 -0500, "Jose Arcadio Buendia"

Quote:



>> Why not using DLL's?
>> It's much easier to pass parameters to DLL's

>> Peter

>The two EXEs display forms...Can't use DLLs

>This the code:
>''''''''' This works: starts at default form, but no parms passed....

>Dim CurrentDomain As AppDomain = AppDomain.CurrentDomain()

> CurrentDomain.CreateInstance("SiteSurveyHome2C",
>"SiteSurveyHome2C.frmMatReqList")

>'''''''''' Try to pas parms...This doesn't work  - I get a compile (syntax)
>error on the CreateInstance ... objParms()

>Dim objParms() As Object

>objParms(0) = CType(24, Object)

>Dim CurrentDomain As AppDomain = AppDomain.CurrentDomain()

>''''' Error on the following line objParms()

>CurrentDomain.CreateInstance("SiteSurveyHome2C",
>"SiteSurveyHome2C.frmMatReqList", True,
>Reflection.BindingFlags.CreateInstance, Nothing, objParms(), Nothing,
>Nothing, , )

>Any ideas?  Thanks



Sun, 18 Jul 2004 16:57:03 GMT  
 Really dumb question: How do I call one .EXE from another, passing parms into the constructor?
On Tue, 29 Jan 2002 13:00:06 -0500, "Jose Arcadio Buendia"

Included a zip file with a very easy example. Opne the solution in
test2.
test2 is a dll, and test1 is an exe. If you have VB.net final you
could run the exe in the root

Peter

Quote:



>> Why not using DLL's?
>> It's much easier to pass parameters to DLL's

>> Peter

>The two EXEs display forms...Can't use DLLs



Sun, 18 Jul 2004 17:13:38 GMT  
 Really dumb question: How do I call one .EXE from another, passing parms into the constructor?

Quote:

> Included a zip file with a very easy example. Opne the solution in
> test2.
> test2 is a dll, and test1 is an exe. If you have VB.net final you
> could run the exe in the root

Come on, how often will you post 60 KB attachments? I don't need them. This
is a newsgroup not an FTP server.... :-(  (in other groups you'd already be
in one's killfile...)

Armin



Sun, 18 Jul 2004 19:20:57 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. This is a really really dumb question.

2. Really really stuck on this one. (QBasic Question)

3. how to pass report parms to stored proc as parms

4. pass cmd line parms to exe

5. Shell function - passing exe and doc parms - won't work with space in pathname

6. Passing Parms between EXE

7. Really dumb question about As

8. really dumb question

9. Really dumb question

10. Really dumb textbox newbie question..

11. A really dumb question... OS Detection

12. Really dumb question

 

 
Powered by phpBB® Forum Software