I had an interesting issue a few months ago on a customer site. The customer had sequenced an application and could deploy the said application fine to Windows XP but whenever they deployed it to the Terminal Server/Citrix Farm the application generated an error. The customer raised it over on AppVirtGuru and we got stuck into looking at what was going on.
When the customer tried to execute the application on the Citrix Farm they received this error;
Microsoft Visual C++ Runtime Library
- CRT not initialized
After much sole searching and playing I worked with one of our Escalation Engineers Sasha Loncarevic about this problem and we tracked this down to a timing problem with Citrix Edge Site and the initialization of the Application.
This is what we believe to see happening:
- APP-V starts process suspended, and injects SFTLDR.
- Citrix driver sees process start, and injects csma_ldr.dll (CSMA_LDR.DLL : hook initializer for the Citrix EdgeSight Agent. This DLL will check if the process that it’s trying to inject itself in is in the exclusion list. ), to be loaded via APC.
- APP-V un-suspends the process and SFTLDR initialises itself
During its init it transitions to kernel mode via an IOCTL for a hooked reg read.
- The OS drains the APC queue on completion of the IOCTL, allowing the Citrix DLL to be injected
- This happens whilst SFTLDR is still initialising, and before (in my applications case MSVCR90.dll) has done its own initialisation, hence the error.
After chatting to a few buddies over at Citrix. They suggested some options :
1) Try the EdgeSight Agent 5.3 which has many fixes related to DLL injection BUT if it does fix the issue, you may have to upgrade the EdgeSight Server also…
2) Try to exclude this application process (foo.exe “your applications exe name”) from being hooked by csma_ldr.dll :
Separate any multiple values with a semi-colon.
**There are some caveats to this registry fix:
1. This value must be set on a per-EdgeSight agent basis. Every machine that is expected to encounter this issue would need this registry value. For now, test the fix on a single server.
2. There is no way to configure this from the EdgeSight Server. It must be entered manually or pushed via GPO or some other bulk registry changing technology.
3. This setting will not take effect until the machine is rebooted.
we tested option 2; after a reboot no more problems with our application issue. So, if you need to run Edgesight with your application and having the above error, and the update per option 1 above doesn’t resolve the problem, give option 2 a try to get you back up and working.