John
John

Reputation: 721

Command Line Argument in VB.net

In below image you can see that i have set Commandline arguments in start option, the requirement is i want to set that command line option dynamically through vb.net.

enter image description here

Upvotes: 0

Views: 2015

Answers (1)

Binary Worrier
Binary Worrier

Reputation: 51711

I have dll file which accept Connectionstring as a command line parameter

Sorry but your terminology is confused.

DLL's don't "accept" command line arguments. You may have an object in your DLL that needs a connection string, but having the DLL pick it up from the command line isn't a good idea (it's possible to do so, just unusual).

Rather, in the application that references your dll you pass the connection string on the command line. In the main method of that application you figure out which arg is the connection string, then create an object from your DLL and pass the connection string to the object (possibly on it's constructor).

Is this making sense to you?


// My Object, gets compiled into MyAssembly.dll
public class MyObject
{
    public MyObject(string connectionString){ . . . }
}

// Program.cs, gets compiled into MyProgram.exe
public class Program
{
    public static void Main(string[] args)
    {
        var connectionString = args[0];
        var myObj = new MyObject(connectionString);
        . . .
    }
}

Upvotes: 1

Related Questions