C# obtain paramter values for dll
-
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?
-
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?
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 -
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 KreskowiakEach 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'?
-
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'?
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 -
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 KreskowiakSorry 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.