Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# obtain paramter values for dll

C# obtain paramter values for dll

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sc steinhayse
    wrote on last edited by
    #1

    I have a C# 2008/2010 application that is currently accessed as a dll file and I would like to change the application so that the dll is accessed though as a reference. The code that calls the dll is a process and the code looks like the following:

    Process theProcess = new Process();

    theProcess.StartInfo = new ProcessStartInfo("filename.ext");

    theProcess.StartInfo.Arguments = "args here"

    theProcess.WaitForExit();

    theProcess.Start();

    I want to be able to pass argument values to the dll when it becomes a reference in the 5 programs that call it. My problem is that I do not know how to pass the parameter values when the code is accessed as a reference. Thus can you tell me how to pass argument values to the application when it is accessed as a reference. Is it something in the reference call? Can you show me code and/or tell me how to acoomplish my goal?

    D 1 Reply Last reply
    0
    • S sc steinhayse

      I have a C# 2008/2010 application that is currently accessed as a dll file and I would like to change the application so that the dll is accessed though as a reference. The code that calls the dll is a process and the code looks like the following:

      Process theProcess = new Process();

      theProcess.StartInfo = new ProcessStartInfo("filename.ext");

      theProcess.StartInfo.Arguments = "args here"

      theProcess.WaitForExit();

      theProcess.Start();

      I want to be able to pass argument values to the dll when it becomes a reference in the 5 programs that call it. My problem is that I do not know how to pass the parameter values when the code is accessed as a reference. Thus can you tell me how to pass argument values to the application when it is accessed as a reference. Is it something in the reference call? Can you show me code and/or tell me how to acoomplish my goal?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      First things first. Vocabulary. A .DLL does not take parameters nor is it an application. A .DLL is a library of classes and methods that an application can use. Screwing up the terminology confuses people. You always use a .DLL either by adding a reference to it in another application project, or depending on the .DLL type, can be accessed with P/Invoke (no reference required). If referenced, you usually stick a using statement at the top to import the namespace of the classes you want to use in the .DLL. What you do after that depends on how you've written the code contained in the .DLL. Usually, you create an instance of a class with the code you want to use, then call the methods you need in that class.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      S 1 Reply Last reply
      0
      • D Dave Kreskowiak

        First things first. Vocabulary. A .DLL does not take parameters nor is it an application. A .DLL is a library of classes and methods that an application can use. Screwing up the terminology confuses people. You always use a .DLL either by adding a reference to it in another application project, or depending on the .DLL type, can be accessed with P/Invoke (no reference required). If referenced, you usually stick a using statement at the top to import the namespace of the classes you want to use in the .DLL. What you do after that depends on how you've written the code contained in the .DLL. Usually, you create an instance of a class with the code you want to use, then call the methods you need in that class.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        S Offline
        S Offline
        sc steinhayse
        wrote on last edited by
        #3

        Each program basically calls the dll with the paramters that is needed for the current run of the dll. The parameters change depending upon what the dll is expected in call. Here is an example of a call that is made:

        strConsoleAppLocation = ConfigurationManager.AppSettings["dll_location"];
        string Process_Arguments = null;
        Process RPT_Process = new Process();
        RPT_Process.StartInfo.FileName = strConsoleAppLocation;
        Process_Arguments = " 7 " + strCUSTID + " 1";
        RPT_Process.StartInfo.Arguments = Process_Arguments;
        RPT_Process.Start();
        RPT_Process.WaitForExit();
        RPT_Process.Dispose();

        Thus do you have any suggestions on how to change the code listed above so that I can attach the dll to each program as 'project reference'?

        D 1 Reply Last reply
        0
        • S sc steinhayse

          Each program basically calls the dll with the paramters that is needed for the current run of the dll. The parameters change depending upon what the dll is expected in call. Here is an example of a call that is made:

          strConsoleAppLocation = ConfigurationManager.AppSettings["dll_location"];
          string Process_Arguments = null;
          Process RPT_Process = new Process();
          RPT_Process.StartInfo.FileName = strConsoleAppLocation;
          Process_Arguments = " 7 " + strCUSTID + " 1";
          RPT_Process.StartInfo.Arguments = Process_Arguments;
          RPT_Process.Start();
          RPT_Process.WaitForExit();
          RPT_Process.Dispose();

          Thus do you have any suggestions on how to change the code listed above so that I can attach the dll to each program as 'project reference'?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          This is such a CF... The path returned by "dll_location" is not a "DLL" but an .EXE. You're passing a few parameters to it in the StartInfo.Arguments. You can't do that with a .DLL, so you're really not using the correct terminology. This means we're having a really hard time figuring out what talking about and what's going on.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          S 1 Reply Last reply
          0
          • D Dave Kreskowiak

            This is such a CF... The path returned by "dll_location" is not a "DLL" but an .EXE. You're passing a few parameters to it in the StartInfo.Arguments. You can't do that with a .DLL, so you're really not using the correct terminology. This means we're having a really hard time figuring out what talking about and what's going on.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            S Offline
            S Offline
            sc steinhayse
            wrote on last edited by
            #5

            Sorry about that! You can correct that I am going an exe. I have this question in another thread of mine so I will just close this thread.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups