473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to run a class from the command line?

In Java you can execute a single class from the command line using the
command:

java.exe <classname> [args...]

As long as the class in question has a method declared as "public static
final main( String[] args )"

How might I execute a Visual Basic .Net class from the command line
*without* building it as a separate "console" project?

Thanks.
Nov 20 '05 #1
6 2605
"Robert Dobson" <tr****@hotmail.com> schrieb
In Java you can execute a single class from the command line using
the command:

java.exe <classname> [args...]

As long as the class in question has a method declared as "public
static final main( String[] args )"

How might I execute a Visual Basic .Net class from the command
line *without* building it as a separate "console" project?


You can not "run classes", but you can run an application. The start
procedure is Sub Main. It can either be a WinForms or a Console application.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
OK, then how about building a "console application" that executes arbitrary
classes? How would I go about coding up a "dotnet.exe" that takes as a
command line argument the name of another class (assuming to be contained in
an included DLL) that will be executed. How do you instantiate and call
methods on a class that's defined at runtime via a string value? Thanks.

dotnet.exe <class to execute> [args passed to class...]

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
"Robert Dobson" <tr****@hotmail.com> schrieb
In Java you can execute a single class from the command line using
the command:

java.exe <classname> [args...]

As long as the class in question has a method declared as "public
static final main( String[] args )"

How might I execute a Visual Basic .Net class from the command
line *without* building it as a separate "console" project?
You can not "run classes", but you can run an application. The start
procedure is Sub Main. It can either be a WinForms or a Console

application.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
"Robert Dobson" <tr****@hotmail.com> schrieb
OK, then how about building a "console application" that executes
arbitrary classes? How would I go about coding up a "dotnet.exe"
that takes as a command line argument the name of another class
(assuming to be contained in an included DLL) that will be executed.
How do you instantiate and call methods on a class that's defined at
runtime via a string value? Thanks.

dotnet.exe <class to execute> [args passed to class...]


Why not write a library and reference it to execute code in it?

At runtime or as a user I am actually not interested in the class names -
but:

To get the command line:
- Microsoft.VisualBasic.Interaction.Command
- System.Environment.GetCommandLineArgs
- Shared Sub Main(byval Args() As String)

See also:
System.Activator.CreateInstance

and:
http://msdn.microsoft.com/library/en...natruntime.asp
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
* "Robert Dobson" <tr****@hotmail.com> scripsit:
OK, then how about building a "console application" that executes arbitrary
classes? How would I go about coding up a "dotnet.exe" that takes as a
command line argument the name of another class (assuming to be contained in
an included DLL) that will be executed. How do you instantiate and call
methods on a class that's defined at runtime via a string value? Thanks.

dotnet.exe <class to execute> [args passed to class...]


Have a look at "vbc.exe", this will compile an executable file from the
source code provided in files passed in the command line parameters.
After compilation, you can run the "class" by starting the compiled
executable.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5
* "Robert Dobson" <tr****@hotmail.com> scripsit:
In Java you can execute a single class from the command line using the
command:

java.exe <classname> [args...]

As long as the class in question has a method declared as "public static
final main( String[] args )"

How might I execute a Visual Basic .Net class from the command line
*without* building it as a separate "console" project?


This cannot be done. In fact, including the 'void main' in Java will
provide an entry point too.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6
Robert,
I would consider using the classes in System.CodeDom.Compiler to load &
compile your source. Specifically the CodeDomProvider class & ICodeCompiler
interface.

Indirectly you would be using one of:
- Microsoft.VisualBasic.VBCodeProvider
- Microsoft.JScript.JScriptCodeProvider
- Microsoft.CSharp.CSharpCodeProvider
- other code providers for other languages.

This will allow your dotnet.exe to include other languages or any language.
Similar to how wsdl.exe & ASP.NET allows any .NET language! (hint I would
use the same parameters as wsdl.exe & the other .NET sdk tools)

Hope this helps
Jay

"Robert Dobson" <tr****@hotmail.com> wrote in message
news:uH**************@TK2MSFTNGP11.phx.gbl...
OK, then how about building a "console application" that executes arbitrary classes? How would I go about coding up a "dotnet.exe" that takes as a
command line argument the name of another class (assuming to be contained in an included DLL) that will be executed. How do you instantiate and call
methods on a class that's defined at runtime via a string value? Thanks.

dotnet.exe <class to execute> [args passed to class...]

"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
"Robert Dobson" <tr****@hotmail.com> schrieb
In Java you can execute a single class from the command line using
the command:

java.exe <classname> [args...]

As long as the class in question has a method declared as "public
static final main( String[] args )"

How might I execute a Visual Basic .Net class from the command
line *without* building it as a separate "console" project?


You can not "run classes", but you can run an application. The start
procedure is Sub Main. It can either be a WinForms or a Console

application.


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Nov 20 '05 #7

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

Similar topics

4
by: Edvard Majakari | last post by:
Hi, I was wondering what would be the most elegant way for creating a Python class wrapper for a command line utility, which takes three types of arguments: 1. options with values (--foo=bar)...
5
by: Shapper | last post by:
Hello, I am working in a web site where all the code is placed in aspx.vb files. After a while I realized that many functions included in my aspx.vb files where common to all pages. I...
9
by: craig.overton | last post by:
All, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and...
0
by: Herman Jones | last post by:
I'm getting the following error when I build a Class Library project: Embedding manifest... Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'. It happens with...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
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...

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.