How to kill a process without getting a “process has exited” exception?

You could P/Invoke TerminateProcess passing it Process.Handle. Then manually evaluating the cause of it (GetLastError()). Which is roughly, what Process.Kill() does internally. But note that TerminateProcess is asynchronous. So you’d have to wait on the process handle to be sure it is done. Using Process.Kill() does that for your. Update: Correction, Process.Kill() also runs asynchronously. … Read more

How to control appearance of ‘:’ in time zone offset when parsing/formatting Datetime

Doesn’t look like there is anything built-in (you can use zz, but that leaves out the minutes). You can roll your own by instantiating a DateTimeFormatInfo, setting TimeSeparator to string.Empty and using that as the IFormatProvider when calling DateTime.ToString (and make the call explicit, if it is not already). But frankly, using Replace to remove … Read more

Call C# dll from Delphi

You may have more luck skipping the COM part by using my project template for unmanaged exports class MyDllClass { [DllExport] static int MyDllMethod(int i) { MessageBox.Show(“The number is ” + i.ToString()); return i + 2; } } In Delphi, you’d import it like so: function MyDllMethod(i : Integer) : Integer; stdcall; extern ‘YourAssembly.dll’; I … Read more

Two Types not equal that should be

The same class / type loaded by different app domains [.NET] or class loaders [Java] will not compare equal and are not assignable to/from each other directly. You likely have two copies of the DLL containing that type – one loaded by the main program and one loaded by one of the Assembly.Load*(…) methods? Try … Read more

Can Ruby import a .NET dll?

While IronRuby will make short work of talking to your .NET dll (it’ll be literally no code at all), it was abandoned by microsoft, and it never got a large enough open source community to keep it going after that event. I wouldn’t recommend it these days Regarding the COM solution, this may actually be … Read more

How to check if process is not responding?

There is no general solution to this problem. It is impossible to tell if a particular process is hanging or not, because the term “hanging” is entirely dependent upon the context of the process that is executing. The hanging process will always do what it was coded to do. The developer may have coded it … Read more