Running dotTrace command line against a windows service
I'm trying to profile a remote service using dotTrace. I see remote profiling is no longer available so I installed the command line tool on the server, and am generally managing to get a snapshot when attaching to the running process provided I am running as an admin user. However a couple of things concern me:
- One attempt to disconnect from the profiling session got stuck and after pressing Ctrl-C several times the service I was profiling died. Is this a common possibility, as I really don't want to be accidentally killing a production server? Are there any ways to prevent this happening?
- On another attempt the attach timed out, and a subsequent attempt failed with the message: “Unable to start profiling. Can't attach CLR profiler: CORPROF_E_PROFILER_ALREADY_ACTIVE The request to attach a profiler was denied because a profiler is already loaded.”. Subsequent attempts get the same message so looks like a profiler is stuck, but I can't find any obvious processes to kill. What do I do in this scenario?
Currently I'm only experimenting with a test service, so am free to restart things at will. However we really need to attach to a production service when we see slowdowns, but I don't want to compromise the service any further so are there any recommendations to prevent the above situations happening? If I can't disconnect from the command line I would need to know which process to kill to to stop the attached profiling session
Please sign in to leave a comment.
Hi!
This issue has been fixed and will be included in the 2025.1.1 bugfix.
Could you please provide us with the list of environment variables for this process? You can see them e.g. using Process Explorer tool.
Thank you - I'm presuming you mean environment variables for the process I'm trying to profile? I have checked and the are none
Yes, I mean the process you're trying to attach to.
This message says that other profiles have already been loaded. It could be another profiling tool installed on your machine or a previous dotTrace instance that was terminated improperly. Could you please check the list of .dlls for the 'profiled' process and find any .dlls potentially related to the profiler? Our .dll is named 'JetBrains.Profiler.Core.dll'. You can do this using Process Explorer as well.
We don't have any other profiling tools installed and I ran successful profiles a couple of times shortly before so I think it will have been a previous dotTrace instance that terminated improperly. The previous attempt timed out so that was probably the one left hanging. However I eventually restarted the service so there are no issues currently. I can see the JetBrains dll when I restart the profiler.
When will the 2025.1.1 bugfix be released? I've had 2 more instances of the service restarting this afternoon already
We decided to cherry-pick this fix to the 2025.1 release. It is expected to be released approximately at the end of April.
Hi, I'm following up on this having downloaded 2025.1.2 of the command line tool. The first time I tried to run the profiler I got the same error as before:
This is the first time I've attempted to run the profiler in over 2 months - repeated attempts get the same error. There is no Z: drive mapped so I don't really get the message - I also checked process explorer and there is no JetBrains dll to be found. Any clues how I can clear this error?
One thing I don't think I made completely clear - the service I'm trying to profile is running as a windows service. I'm not sure if that makes any difference
Hi!
Could you please provide us with the list of environment variables for the process you are attempting to attach to? You can use Process Explorer to obtain this information.
Hi - same as above there are no environment variables listed in process explorer
It is very uncommon for a Windows process to have no environment variables at all. Did you start Process Explorer with administrator privileges? Windows services run under elevated accounts, so Process Explorer also needs elevated privileges to view the environment variables of such processes.
If dotTrace throws the CORPROF_E_PROFILER_ALREADY_ACTIVE error, it means that another profiler is already injected into the process. This could be another instance of the JetBrains profiler, or it could be caused by a different profiling tool. To investigate further, we need to analyze the list of environment variables and the DLLs embedded in the process. This is why we initially requested information about the environment variables.