473,788 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2619
"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*******@free net.de> wrote in message
news:%2******** *******@TK2MSFT NGP12.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.Visua lBasic.Interact ion.Command
- System.Environm ent.GetCommandL ineArgs
- Shared Sub Main(byval Args() As String)

See also:
System.Activato r.CreateInstanc e

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.Visua lBasic.VBCodePr ovider
- Microsoft.JScri pt.JScriptCodeP rovider
- Microsoft.CShar p.CSharpCodePro vider
- 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******** ******@TK2MSFTN GP11.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*******@free net.de> wrote in message
news:%2******** *******@TK2MSFT NGP12.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
2781
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) 2. boolean options (--squibble) 3. data lines (MUNGE:x:y:z:frob)
5
1336
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 created a new file named common.vb where I created a class named common and where I place all common functions:
9
8337
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 download a file no problem. My issues come when I try to use the same class with the same commands to access an FTP server on a UNIX box. I can connect and login just fine, but after that all my commands come back "500 'PWD': command not understood."....
0
6611
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 every the of C++ project I try to build. Not just Class Libraries, but a plain Windows Form Application as well. I've tried creating new projects with nothing but shell built by the Wizard, but I still get the error.
0
9656
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
10173
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
10110
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
9967
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
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
5399
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
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3674
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.