none
Is it possible to create a C# DLL that has command line arguments RRS feed

  • Question

  • Hi

    I would like to create a DLL that has commald line arguments

    i.e. c:\TestCalc.DLL /Operator:"Add" /ValOne:1 /ValTwo:3

    Output: 4

     

    Is it possible to do this and what should the code look like?

     

     


    • Edited by Fabfella Monday, November 7, 2011 1:23 AM
    Monday, November 7, 2011 1:23 AM

Answers

  • DLL's cannot be run like that.  The closest would be to use rundll32.exe, which is able to call LoadLibrary() and call the specified DLL function with the specified arguments.

    But in C# you can't export functions, so even rundll32 is out of the question for your particular case.

    In your case, you should examine/study .net Reflection.  I have a hunch is what you need.


    Jose R. MCP
    • Edited by webJose Monday, November 7, 2011 1:51 AM
    • Marked as answer by Fabfella Monday, November 7, 2011 2:19 AM
    Monday, November 7, 2011 1:50 AM

All replies

  • DLL's cannot be run like that.  The closest would be to use rundll32.exe, which is able to call LoadLibrary() and call the specified DLL function with the specified arguments.

    But in C# you can't export functions, so even rundll32 is out of the question for your particular case.

    In your case, you should examine/study .net Reflection.  I have a hunch is what you need.


    Jose R. MCP
    • Edited by webJose Monday, November 7, 2011 1:51 AM
    • Marked as answer by Fabfella Monday, November 7, 2011 2:19 AM
    Monday, November 7, 2011 1:50 AM
  • Thanks for the response WebJose
    Monday, November 7, 2011 2:20 AM