|
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.
|
|
|
|
|
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'?
modified 28-May-13 15:27pm.
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
Hi Friends...
I would Like Add some live channels in my website from where i can start. do i need to pay for them...?.
if so how much it would be..?
is ther any free servers/freelivestreams..?
|
|
|
|
|
Wrong forum; this is for technical questions on C#. Google is the place you want.
Use the best guess
|
|
|
|
|
Hi all,
I am having a problem with a databound combobox in that when I save the record (ie, end current edit,update the database and accept the changes) the combobox resets its value back to the first object in the list.
Anyone else experienced this problem before?
Thanks & Regards
Thahir
|
|
|
|
|
What platform (i.e. web classic, web MVC, WinForms, WPF)?
|
|
|
|
|
|
Run through your code and ensure that the combobox is not reassigned datasource / values.
The combo will refresh in this case.
To avoid this, you can actually store the present value locally and then reassign to combo once save action completes.
|
|
|
|
|
I am running from source code, while I am calling this command "this.BindingContext[data[1, 0]].EndCurrentEdit();" it is resitting to the original value.
|
|
|
|
|
I have a win form application in which i have to move a picture box with arrow keys.
The problem is that when other controls like text boxes are added in the form at run time and then picture box losses its focus on pressing arrow key and picture box does not move.
please help me..
|
|
|
|
|
Firstly if this is VB I would put in the VB Forum[^].
Secondly you haven't shown any code snippets etc.
My first thought is that if you are using code to draw your controls rather than drag and drop from the designer can't you change the order that they are drawn?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
IIRC, a PictureBox cannot have focus while in the same container with a TextBox regardless of the order of instantiation. I think it's because usually there is no need to interact with a PictureBox. It just exists to display a picture.
Ciao,
luker
|
|
|
|
|
Thanks have learnt something new today.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I don't know your control stack. But Form[^] has a boolean KeyPreview[^] property. Set it to true and handle the cursor keys outside of the picturebox. Or catch it outside and redirect it where you need it.
Ciao,
luker
|
|
|
|
|
focus picture box when entering form[^]
As Lukeer has stated the picturebox can not have focus as it is only designed to display a picture rather than accept keyboard presses.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Hi guys,
I created a 3x3 puzzle game and I randomize the button at form load.
It's a success, but sometimes I can't solve the puzzle no matter how hard I try.
This is where the puzzle stuck at,
http://i39.tinypic.com/9k17dh.jpg[^]
Maybe there is a way to random puzzle?
Or maybe I don't know how to play puzzle?
|
|
|
|
|
Usually it's called "8-puzzle" (special case of N-puzzle), and exactly half of them are unsolvable.
You can check whether it's solvable[^] and then generate a new one if it isn't.
|
|
|
|
|
There are a couple of ways to randomise it:
1) Insert each piece of the puzzle at a random location on the board, by using the random number generator to specify the location. This is quick to generate, but as Harold says, it can generate puzzles that can't be solved - you need a post-processing step to ensure that it can.
2) Use the random number generator to generate a direction, and move the pieces that way, exactly as if the user had done so. You then repeat this a number of times to "scramble" the puzzle. This is slower to generate, but the result is always solvable, and it means that a "difficulty level" can be added very simply by changing the number of times the random move is implemented.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
I thought about that second method, but concluded that I couldn't guarantee anything about how random the result would be, so I decided against recommending it.
It could be faster though, the way I mentioned has a probability of 0.5 at every step to terminate, you could have bad luck.
|
|
|
|
|
It generally works out pretty random: since at any stage you will have 4, 3, or two possible moves (depending on where the hole is in respect of the edges) it's a pretty simple matter to "ban" the move which reverses the previous one. That does give good randomness in practice - it's down to how many iterations you go for.
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
I suppose so, but I had to think of that argument for why the "swap any two random elements n times" algorithm doesn't shuffle an array correctly - some configurations have more paths to them than others, so they get chosen too often.
I'm not sure that isn't the case here.
|
|
|
|
|
I was able to solve it using a timer that randomly click the movable button in 5 second and it worked.
Thank you very much for the help guys.
|
|
|
|