I am trying to instrument our application looking for performance optimizations, but I cannot manage to get any data out of it. I am mainly interested in function running times and how many times where they were called.
Can you point to the flaw in my process please?
Here is what I do:
1. VSInstr MyAssembly.dll
This creates the instumented dll (like twice the size) and backs up the original.
I get a warning about strong-named things so step 2
2. sn -Ra MyAssembly.dll TheKeyFile.snk
Says resigning is successfull
3. VsPerfCLREnv /traceon
Setting up environment variables
4. Running the program. I go right before the step I want to investigate.
5. VsPerfCmd /start:trace /output:../Reports/Report.vsp
Starting the trace
6. Clicking the button to do the process (app creation) and waiting to finish
7. VSPerfCmd /shutdown
Stop tracing.
8. VSPerfCLREnv /off
Reset environment to normal
At the end of all this I check the Report.vsp file. It is a 148KB file which when opened in VS2017 throws these two error popups and fails to open anything:
File contains no data buffers
Failed to analyse report
The solution was to
Use /globaltraceon instead of /traceon
First run VsPerfCmd /start:trace and only start the service afterwards
Call VSPerfCmd /processon:[PID] to attach to process
Stop the service when finished ( /shutdown won't complete otherwise)
So the steps looked like this:
VSInstr MyAssembly.dll
sn -Ra MyAssembly.dll TheKeyFile.snk
VsPerfCLREnv /globaltraceon
Set service on Manual startup
Restart computer
VsPerfCmd /start:trace /output:Reports/Report.vsp
Start service manually
VsPerfCmd /processon: (look up in Task Manager)
Do whatever you want to measure
Stop service
VsPerfCmd /shutdown
Related
I am writing a Crystal Report Viewer in Visual Studios using ClickOnce to deploy updates and install on users computers. I am using Visual Studios C# and have the application checking for updates before loading the program to ensure all users have the latest version when needed.
One thing that I did not think about and just ran into is the number of reports attempting to load at once on a machine. Some users have 10+ reports starting simultaneously when they log into our ERP. I made a batch file to start all the reports they needed but I ran into an error:
Too many deployed activations are attempting to load at once
I tried searching for an answer as to how many ClickOnce instances are allowed to load at once and I could not find the answer. It seems to be around is 8 (based on my testing) and apparently it is in place to prevent DOS attacks against the ClickOnce server. I tried waiting a few seconds in the batch file after every 5 reports or so but this is not a long term solution.
Is there a way to increase this limit or should I just open all the reports needed in a single instance from a command? Even if I go with the second option, users can still add reports to automatically open in the ERP causing this issue to arise again. So is there a way to detect how many ClickOnce instances are currently loading and wait for them to finish, allowing me to bypass this issue entirely?
The solution I came up with for this was to expand the command to include multiple reports so all the reports will open under the same program. That way, ClickOnce is only involved once per batch file. Each report runs in its own thread so it behaves the same as running each report as a new instance of the program.
Theoretically a user could add enough batch files to our ERPs auto launch feature to overload the system and receive the same error as before but we could just add that to the batch file once we find out.
Until I find out if there's any way around this limit, this is the best I can come up with since it seems to be happening before the program even hits main().
I have a Windows Forms Application written on C# and it targets .net framework 4.8.
I run this application on Windows 7 x86 on the customer's PC. My application works fine but time to time I have a mystic problem with its launch. Sometimes my application just refuse to start but when I open process explorer I see MyAplication.exe which holds 1MB of RAM. It seems that something is blocking my application.
I examined windows events log but there are no errors. I also tried to write into the log file on the first line of Program.cs but it simply doesn't happen. I kill this 1 MB process and restart my application. It opens and work just fine or I have to restart it few times. I have experienced this kind of 1 MB RAM problem with my another WPF application and even with .net application from an external vendor. I created a dump file for my application using process explorer.
On my personal PC on Windows 10 I used WinDbg application from the Windows Store to analyze dump file of my application. I see the following:
FAULTING_THREAD: 000002a0
PROCESS_NAME: MyApplication.exe
ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION} Breakpoint A breakpoint has been reached.
EXCEPTION_CODE_STR: 80000003
MISSING_CLR_SYMBOL: 0
STACK_TEXT:
002be670 77176c04 ntdll!KiFastSystemCallRet+0x0
002be674 771765ac ntdll!NtWaitForSingleObject+0xc
002be678 77161db1 ntdll!RtlpWaitOnCriticalSection+0x13e
002be6dc 77161c95 ntdll!RtlEnterCriticalSection+0x150
002be704 76e5cc0f rpcrt4!PerformRpcInitialization+0x29
002be748 76e665fd rpcrt4!RpcStringBindingComposeW+0x15
002be758 72ab1ec0 DialogFilterProc!InitDialogFilterProc+0x32d
002be810 72ab18b3 DialogFilterProc!ReleaseDialogFilterProc+0x17d
002be828 72ab2157 DialogFilterProc!InitDialogFilterProc+0x5c4
002be844 72ab22be DialogFilterProc!InitDialogFilterProc+0x72b
002be8a4 771887cc ntdll!LdrpCallInitRoutine+0x14
002be8c4 77195adb ntdll!LdrpRunInitializeRoutines+0x26f
002be9b8 7718faf2 ntdll!LdrpLoadDll+0x472
002beb2c 77192105 ntdll!LdrLoadDll+0xaf
002beb64 7523b246 KERNELBASE!LoadLibraryExW+0x215
002bebac 772aefa4 user32!__ClientLoadLibrary+0x60
002bece0 77176b3e ntdll!KiUserCallbackDispatcher+0x2e
002bed7c 772b4f21 user32!NtUserMessageCall+0xc
002bed80 772e5d6e user32!CallNextHookEx+0x10b
002bedb0 6d460ef0 tiptsf!TabletCallWndProc+0x5f
002bedd0 772a7a02 user32!DispatchHookW+0x33
002bedec 772a4999 user32!fnHkINLPCWPSTRUCTW+0x52
002bee20 772ae952 user32!__fnINLPCREATESTRUCT+0x8b
002bee50 77176b3e ntdll!KiUserCallbackDispatcher+0x2e
002beec4 772aeb5c user32!NtUserCreateWindowEx+0xc
002beec8 772aeaf0 user32!VerNtUserCreateWindowEx+0x1a3
002bf16c 772aec1c user32!_CreateWindowEx+0x201
002bf218 772aec77 user32!CreateWindowExW+0x33
002bf254 7682633f ole32!InitMainThreadWnd+0x3e
002bf28c 768263fc ole32!wCoInitializeEx+0xef
002bf2a4 768209ff ole32!CoInitializeEx+0x2ee
002bf2c4 7124ab8f clr!Thread::SetApartment+0x13b
002bf310 7123e1b7 clr!SystemDomain::SetThreadAptState+0x92
002bf330 7123e892 clr!SystemDomain::ExecuteMainMethod+0x18c
002bf810 71242498 clr!ExecuteEXE+0x4c
002bf868 712425be clr!_CorExeMainInternal+0xdc
002bf8a8 7123def5 clr!_CorExeMain+0x4d
002bf8e4 7185fa84 mscoreei!_CorExeMain+0xd6
002bf91c 718e7f16 mscoree!ShellShim__CorExeMain+0x99
002bf92c 718e4de3 mscoree!_CorExeMain_Exported+0x8
002bf934 7616ef3c kernel32!BaseThreadInitThunk+0xe
002bf940 77193618 ntdll!__RtlUserThreadStart+0x70
002bf980 771935eb ntdll!_RtlUserThreadStart+0x1b
SYMBOL_NAME: DialogFilterProc!InitDialogFilterProc+32d
MODULE_NAME: DialogFilterProc
IMAGE_NAME: DialogFilterProc.dll
STACK_COMMAND: .ecxr ; kb ; dt ntdll!LdrpLastDllInitializer BaseDllName ; dt ntdll!LdrpFailureData ; ** Pseudo Context ** Pseudo ** Value: 88f6c30 ** ; kb
FAILURE_BUCKET_ID: BREAKPOINT_80000003_DialogFilterProc.dll!InitDialogFilterProc
OSPLATFORM_TYPE: x86
OSNAME: Windows 7
IMAGE_VERSION: 1.0.299.0
FAILURE_ID_HASH: {e56a1c21-26f9-3e25-d015-b9f79339b457}
Followup: MachineOwner
P.S: I disabled antivirus and windows defender but it didn't solve my problem.
I have no internet access on the customer's PC. Not sure if it can have an impact on my problem.
Can anyone help me with this mystic problem? Any ideas are much appreciated!
Lets read the call stack
clr!_CorExeMain
clr!_CorExeMainInternal
Main Method of managd code reached (SystemDomain::ExecuteMainMethod)
clr!ExecuteEXE
clr!SystemDomain::ExecuteMainMethod
clr!SystemDomain::SetThreadAptState
You most probably have an STAThread Apartment attribute on your Main method because
there a COM Appartmentstate is set Thread::SetApartment
clr!Thread::SetApartment
COM initializes (CoInitializeEx)
ole32!CoInitializeEx
ole32!wCoInitializeEx
ole32!InitMainThreadWnd
COM needs a hidden window to pump messages (CreateWindowExW)
user32!CreateWindowExW
user32!_CreateWindowEx
user32!VerNtUserCreateWindowEx
user32!NtUserCreateWindowEx
ntdll!KiUserCallbackDispatcher
user32!__fnINLPCREATESTRUCT
user32!fnHkINLPCWPSTRUCTW
user32!DispatchHookW
Something in this case tiptsf has hooked (DispatchHookW) into window creation to inject its own functionality (TabletCallWndProc). This one is from Microsoft Ink I suspect.
tiptsf!TabletCallWndProc
user32!CallNextHookEx
user32!NtUserMessageCall
ntdll!KiUserCallbackDispatcher
user32!__ClientLoadLibrary
This loads some extension dll
KERNELBASE!LoadLibraryExW
ntdll!LdrLoadDll
ntdll!LdrpLoadDll
ntdll!LdrpRunInitializeRoutines
ntdll!LdrpCallInitRoutine
Now we initialize DialogFilterProc which had problems in Windows 7 around 2012
On my Win10 machine I do not have this DialogFilterProc found. Is this a Windows 7 machine? This one is not documented at all so there is little information what this one tries to do here. According to this it seems to be a System Service which could be disabled, hence the hang.
DialogFilterProc!InitDialogFilterProc
DialogFilterProc!InitDialogFilterProc
DialogFilterProc!ReleaseDialogFilterProc
DialogFilterProc!InitDialogFilterProc
The DialogFilter calls RpcStringBindingComposeW which apparently hangs. From the docs
I can see that it deals with inter process communication.
Either the COM apartment was not yet fully initialized which cause this RPC method to hang or the remote connection could not be established.
See e.g. here for an example where this method is used.
rpcrt4!RpcStringBindingComposeW
rpcrt4!PerformRpcInitialization
ntdll!RtlEnterCriticalSection
ntdll!RtlpWaitOnCriticalSection
ntdll!NtWaitForSingleObject
ntdll!KiFastSystemCallRet
If the first issue is the premature loading of Microsoft Ink you can try to disable it and check if that works around your issue. If the issue persists you can try set on your main method the [STAThread] or [MTAThread] attribute. Perhaps another apartment mode will also resolve your deadlock.
Or if that is really the Dialog Filter which tries to call into a service which did crash or was not running then you need to restart the service to make your UI pop up.
As I could (hopefully) show you it is pretty easy to find out from any method what it is doing and how it can be turned off. Based on that you should have now plenty of further options to explore either the actual root cause or find a dirty workaround.
Addenum
Your DialogFilterProc.dll has version 1.0.299.0 which seems to be older than the one in the fix from 2012 which has 1.0.542.0. Installing the ancient fix could be the solution to your problem.
> File name File version File size Date Time Platform
> Dialogfilterproc.dll 1.0.542.0 13,312 24-Jul-12 17:11 x86
When I run my selenium framework it runs as a process. There is no user interface. It runs until it completes or until it encounters an exception that stops the test. Currently, the only way to manually stop the test is to kill the process in Task Manager.
I would like the user to be able to press a key, like escape, to stop the process.
I've only so far been able to find such functions related to a project running in a console
You could create a batchfile with the following contents:
taskkill /F /FI "IMAGENAME eq notepad.exe"
(replace 'notepad.exe' with the correct program name)
When you create a link to that batch-file, you can also specify a 'Shortcut key' to start this batchfile.
Thank you Luuk. To work around I created a batch file that is now included in the build.
Note: While my sample code is in Powershell, I could easily convert a C# sample into Powershell. I believe that C# developers are more likely to have encountered this issue, even though I am using Powershell to try and do this.
I am trying to debug an issue with server-side Word automation. I know that you're not meant to use it for server applications and we are in the process of changing the application so it doesn't do this but until this happens I need a reliable way to debug issues where it hangs as it does so randomly.
It is not OK for me to just switch .Visible = True on the Word object because it doesn't fail all the time. I just need a way to retrieve it every now and again when it does.
If I start Word and execute this script, it works:
$w = [System.Runtime.InteropServices.Marshal]::GetActiveObject("Word.Application")
$w.Visible = $false;
Start-Sleep -Seconds 5
$w.Visible = $true;
However, if the hanging copy of Word starts as invoked by the COM+ process, the following exception occurs:
Exception calling "GetActiveObject" with "1" argument(s): "Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))"
The Powershell and COM+ process run under the same user, and in Task Manager they both show up as running under the same user.
I have tried running Powershell as all combinations of elevated/non-elevated and x86/x64 modes to no avail.
Therefore I assume the process is in another context or area that I am not able to access from my Powershell session.
So my question is one of:
How can I launch the Powershell process as part of the COM+ process?
How can I switch my context so I can access this object instance?
Is there any other way I can try and retrieve this hidden window and set it to visible?
Unfortunately, most questions that seemed to revolve around this theme end with someone saying "well, don't do that then". Sadly we don't have an option to redevelop this significant part of the system at the moment and I would like to get this documented for those of us who have to deal with these legacy systems from time to time.
i made a windows service & add project installer.in which only contain this code.
System.Diagnostics.Process.Start(#"C:\Windows\system32\notepad.exe"); inside the timer tick event & interval is 60 sec.i just wanted to try to run Windows service.
1st-serviceProcessInstaller1 i have been changed its account setting as local system.
2nd-serviceInstaller1 in this case i have been changed its start up type as Automatic.
then i create a setup add another project then right click add project output then add primary output then press ok.
then go to Right click on project->view->custom Action->right click on Install->Add custom Action->select Application folder & add primary output.the same thing done for all the remaining options like commit,rollback,uninstall.
after that i build the setup it build succesfully then i install the setup it installed properly into program file n create one .exe file n one Instalfile.
but problem is that when i search the service into "services.msc" the service is not there.
means service is not showing there.i tried but not getting the ans.plz help me to solve this problem.
Not the answer to your original question, but
Starting an application with a GUI from a service is a bad idea (tm) and won't work in the majority of cases
Check what kind of Timer you use. .Net provides 3 Timer classes, not all of them work in a service (because they depend on a window's message loop, iirc)
To test any service: Why don't you go for the installutil binary first (bypassing the setup project)? You find it in your framework directory, for example in "C:\Windows\Microsoft.NET\Framework\v2.0.50727".
I'd suggest trying to install the assembly manually to see if you get any kind of error message.
Just open a Visual Studio command prompt and run InstallUtil.exe [YourService].exe. At least you'll know if it installed properly.
Even better option is to use the command line tool sc.exe
Try "sc create /?" on command line and see its options.
You can then use "sc start " , "sc stop " & "sc query " to control service. You can use sc.exe to send custom command to the service. Check windows event log for errors related to service installation. It may be .Net version used to create it is not on target machine.