|
I have created a windows service that looks for the existence of a running process and if the process does not exist it will start it. So far this works great, however I have a scenario where sometimes this process will be running multiple times for different customers. When it is kicked off for a customer, their ID is passed as an argument when the process starts up. Is there any way to see what arguments are being used in a running process? I have looked at using remoting, but it seems like overkill to get the info that I need. I also looked at setting the MainWindowTitle so I can look at that, but that doesn't seem to work either. In a nutshell, I want to say is process A running, Yes then for who?
Any help would be appreciated.
Thanks
Sean
|
|
|
|
|
Couldn't you just use a Mutex. Have the process create a Mutex with a name that includes its customer Id. If the expected mutex exists, the customers process is running.
This may be simpler than running through all the processes and has the added benefit of preventing duplicate executions of an individual customers application.
|
|
|
|
|
The mutex looks like it will work great. Thanks
Sean
|
|
|
|
|
UTRocketFan wrote: In a nutshell, I want to say is process A running, Yes then for who?
Maybe you mean Process.Username property? It's available only in .Net 2.0 though.
Regards
|
|
|
|
|
The project I'm currently working on high level has 3 primary projects:
<solution>
|-> Definitions [dll]
|-> ClientConsole [exe]
|-> ServerConsole [exe]
Definitions project has no references. ClientConsole is an exe that will be distributed on clients and references "Definitions" project.
ServerConsole is an exe that will be distributed on server(s). But the requirements allow, server to present itself as a client and thus be an acting "client".
My question:
How do I add "ClientConsole" as a reference to the "ServerConsole" project as the server needs to be able to instantiate the client related objects (UI, other classes). The "Add Reference" fails since "ClientConsole" is of type exe.
I can NOT make "ClientConsole" a class-library and add a new additional EXE project just for launching the ClientConsole.
I have tried all of the following:
1. Keep ClientConsole an exe, and as a "Post build event" on "ClientConsole" project to copy and rename itself as a DLL to the references folder of "ServerConsole" project. This does not work because ...
a) Visual Studio locks the DLLs and thus the new DLL cannot be copied to the destiation folder
b) Even if VS does not lock the file, the intellisense will not reflect the changes in ClientConsole when editing code for ServerConsole when "ClientConsole" is updated
2. Change ClientConsole to a DLL project, and add it as a project reference to ServerConsole. I'll have solved my issue with intellisense and VS picking up the correct DLLs. And as an icing on the cake, set the "post build event" on "ServerConsole" project to rename the "ClientConsole.dll" file to "ClientConsole.exe". This is an ideal solution for me, but this also bomb because ...
a) when the client is compiled as a DLL, the entry poing info "Main()" is not defined so renaming the DLL to an EXE throws error that it's an invalid Win32 app.
I'm sure I'm not the first one to encounter this error. What do you suggest?
Thanks,
- Malhar
|
|
|
|
|
malharone wrote: I can NOT make "ClientConsole" a class-library and add a new additional EXE project just for launching the ClientConsole.
Why not?
malharone wrote: I'm sure I'm not the first one to encounter this error. What do you suggest?
State the obvious and suggest you move the relevant parts to a new Class Library and have ClientConsole become a bootstrap to the controls and forms in the new class library.
|
|
|
|
|
Colin Angus Mackay wrote: Why not?
Unfortunately, where I work, it is the "Business" that makes tbe technical decision. They want to have a simplified client-side deployment process. One additional DLL and the hell breaks loose!
They've dictated that clients should have "Definitions.dll" and the "ClientConsole.exe" only. Rest of the 3rd party dependent references are already installed, so the installer only copies 2 files on the client machine.
Colin Angus Mackay wrote: State the obvious
I was hoping that from the post build event of "ServerConsole", somehow I could recompile the ClientConsole as a WinExe application.
|
|
|
|
|
malharone wrote: the ClientConsole as a WinExe application
hmm.. I could do that.. I should do that given the constraints
|
|
|
|
|
Hi,
We are using data-binding & typed datasets in our C# .NET 2.0 application (VS2005). We have a bindingsource which has as datasource a dataset and as datamember a datatable.
In the form we have a grid which is binded to that bindingsource. We allow new records to be created on the grid.
When the users navigates to a new row, the "Adding New" event is raised. We would like to handle this event because we need to set the key of the record to a new Guid.
We get as parameter of the "Adding New" function "AddingNewEventArgs e".
Then e.NewObject should be set. Well, this doesn't work. After setting the e.NewObject the program crashes.
It's like it does not accept my Typed DataRow. Maybe the collection underneath in the Bindingsource accepts another type?
Any ideas?
Best regards,
Jens
|
|
|
|
|
JensB wrote: we need to set the key of the record to a new Guid.
I did that in several data-bound DataGridViews with no problems. You don't set the e.NewObject to something. Here is how I did it.
private void MyDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
MyDataGridView.Rows[e.RowIndex].Cells[0].Value = Guid.NewGuid().ToString();
}
Regards
|
|
|
|
|
Hello
How can i increase level of run my program in the Win XP
Thanks
|
|
|
|
|
Umm... What is "level of run"?
Regards
|
|
|
|
|
in the work with hardware which interrupt in the XP responced!
Thanks
|
|
|
|
|
That didn't clear things up at all.
Are you asking how to write a driver for a hardware device? Or how your application can communicate with a device? What kind of device?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
If you read that in an article or got some link that would explain what you mean, I'd greatly appreciate it.
Regards
|
|
|
|
|
Do you mean the priority of the application? Where increasing the priority of the application will increase the speed of the application but if set to high it will degrade the performance of the rest of the system?
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
|
|
|
|
|
Hi all,
I've been playing with excell for a bit and i saw that i can import data from a xml file...
Is is possible to do so through c#? 2 export data from xml to excell?
-- modified at 9:55 Tuesday 3rd October, 2006
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hello
You can write your DataSet to Xml text using DataSet.WriteXml() ,ethod. Then you can write it to an Xml file using XmlDocument class.
Regards
|
|
|
|
|
mejojo-
Thank you for your response. I forgot to specify we have not upgraded to the 2.0 framework. We are on 1.1 System.IO.SearchOption opt = System.IO.SearchOption.AllDirectories; does not seem to work.
My first attempt(b4 the post) was
DirectoryInfo di = new DirectoryInfo(@"C:\Temp");
foreach(DirectoryInfo file in di.GetDirectories())
{
Response.Write("File Info \""+file.FullName+"\""+"
");
}
But this does not go into subdirectiories. Can some one help?
What is the best option for displaying the result set to the web, DataGrid? Instead of Console.WriteLine what would I use for the web? From what I was told I a console app is done the same way from a Web App (ASP.NET) but Console.WriteLine does not display my result set.
Thanks in advance.
|
|
|
|
|
Hello
iamnew2C# wrote: I forgot to specify we have not upgraded to the 2.0 framework
I was postulating here in the forum for sometimes that if you want some functionality of a certain library of .Net framework, you can install it on your machine and explicitly reference to that library. So you'd be using .Net 1.1 for everything else, yet enjoy this new feature of .Net 2.0 or even 3.0.
iamnew2C# wrote: But this does not go into subdirectiories
Sure it won't. You have to put this code in a recursive function and recall it each time.
iamnew2C# wrote: What is the best option for displaying the result set to the web
You are enumerating Directories. I guess a TreeView would do the job.
Regards
|
|
|
|
|
static void Main(string[] args)
{
RecursiveGetDir(@"C:\Temp");
Console.Read();
}
static void RecursiveGetDir(string cDir)
{
DirectoryInfo[] dirs = new DirectoryInfo(cDir).GetDirectories();
if (dirs.Length > 0)
{
foreach(DirectoryInfo dir in dirs)
{
Console.Write("File Info \""+dir.FullName+"\\\n");
RecursiveGetDir(dir.FullName);
}
}
}
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Thank you. Could you tell me how I display the results to the web, instead of using Console.write? Is there another class output specific for a web app?
Regards
|
|
|
|
|
The best vehicle for displaying this in a web is using a treeview control.
public void MyForm_Load(object sender, EventArgs e)
{
InitializeComponent();
RecursiveGetDir(@"C:\Windows", myTreeView.Nodes);
Console.Read();
}
static void RecursiveGetDir(string cDir, TreeNodesCollection nodes)
{
DirectoryInfo[] dirs = new DirectoryInfo(cDir).GetDirectories();
if (dirs.Length > 0)
{
foreach(DirectoryInfo dir in dirs)
{
TreeNode node = new TreeNode(dir.FullName);
nodes.Add(node);
RecursiveGetDir(dir.FullName, node.Nodes);
}
}
}
|
|
|
|
|
i am calling a web service method in my windows application
the method returns xml file,i would like to set the Connection
timeout for my web service to 20 minutes,
and the counter is reset to zero everytime you Access any of the functions on the web service
So if you access the web service again within 20 minutes you dont need to log on again,
can any of you refer me to articles or samples
thanks
regards paula
|
|
|
|
|
Hi Paula,
20 minutes sounds like a very long timeout for a webservice. Even stranger is that you want it to reset it when accessing other methods. Why would you want to do this? Are you trying to fake events?
One way to go might be (in .NET 2.0) to use the asynchronous methods of the webservice proxy. You can then easily cancel your original call and re-issue it when you call any other method, but this is not good if it really does take say 15 minutes to return the data you asked for, as you'll keep aborting it and restarting.
Regards,
Rob Philpott.
|
|
|
|