chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
We are running a TFS 2012 build using the TypeMock custom activities of TypeMockStart and TypeMockStop. Seemingly randomly we receive the following error: Exception Message: Access to the path '<xxxxxx>TypeMockdProfileLinker.dll' is denied. (type UnauthorizedAccessException). This happens when TFS tries to clear the directory for the build - so the previous build must have left ProfileLinker.dll locked. But the previous build shows it succeeded. This continues to happen unless we restart the TFS build agent. After we restart the TFS build agent, the next build succeeds.

Possible un/helpful information:
- Looking at the TFS output file of the previous build shows that both TypeMockStart and TypeMockStop were successfully called
- The unit tests for this project can take over 10 minutes
- The solution contains 56 projects, 18 of which are unit test projects
- On another build of a different solution we were able to create this same scenario by stopping the build during the execution of the unit tests - possibly skipping the TypeMockStop activity (did not verify).

Any help you can provide would be appreciated.
asked by BretB (880 points)

12 Answers

0 votes
Hi,

ProfileLinker.dll is attached to all processes profiled by Isolator.
My guess is that one of these processes is not terminated at the end of the TFS build session and ProfileLinker remains attached to it.

I suggest you to use process explorer to find the process that has a handle to ProfileLinker.dll, it should be under the TFS process.
When you find it, figure out why it's kept alive and if it should be terminated in the end of the session.
If this process shouldn't be profiled, send us it's name.

We provide a custom template with Typemock activities already installed in it.
If you have your own custom template , please send us the part with Typemock activities, it's possible that something prevents Stop from being called.

Looking forward to your feedback.
answered by alex (17k points)
0 votes
This error happens randomly, but on average about every 10-15 builds.

We looked through Process Explorer and the TFS Build Agent itself (TFSBuildServiceHost.exe), not a child process, held the reference to ProfileLinker.dll.

Our custom template is based off of the DefaultTemplate.11.1.WithTypemock. We added some customizations: variables for directory names and XML PreProcess. I have attached the file.

In the build prior to the error, we saw that the TypeMockStop activity was successfully executed.

Here are the details of the activities from the build prior to the error (with Company and License masked):

TypeMockRegister00:00:05
Inputs 
License: XXXX-XXXX-XXXX-XXXX-XXXX 
Company: XXXXXXXX
AutoDeployDir: $/XXXX/SharedLibs/Typemock 
Outputs 
AutoDeployDir: $/XXXX/SharedLibs/Typemock 
Source AutoDeploy location is '$/XXXX/SharedLibs/Typemock'
AutoDeploy translated to 'C:XXXXSharedLibsTypemock'
Typemock AppDomain base C:XXXXSharedLibsTypemock
TypeMockRegister, Company='xxxxxxxx', License='XXXX-XXXX-XXXX-XXXX-XXXX', AutoDeploy=True

TypeMockStart00:00:00
Inputs 
Verbosity: Normal 
Target: 
ProfilerLaunchedFirst: False 
Link: 
EvaluationFolder: 
LogPath: 
AutoDeployDir: 
LogLevel: 0 
Outputs 
Version: 
LogPath: 
AutoDeployDir: 
LogLevel: 0 
Leaving AutoDeploy location as is
Setting deploy directory to: C:UsersYYYYAppDataLocalTempBuildAgentAssemblies
Typemock AppDomain base C:UsersYYYYAppDataLocalTempBuildAgentAssemblies
TypeMockStart Target=, ProfilerLaunchedFirst=False, Link=, LogLevel=0, LogPath=, EvaluationFolder=


TypeMockStop00:00:00
Inputs 
Undeploy: True 
AutoDeployDir: 
Outputs 
AutoDeployDir: 
Leaving AutoDeploy location as is
Setting deploy directory to: C:UsersYYYYAppDataLocalTempBuildAgentAssemblies
Typemock AppDomain base C:UsersYYYYAppDataLocalTempBuildAgentAssemblies
TypeMockStop - Undeploy = True



Thank you for your time.

Note: I forgot to mention in my original post that we are running TypeMock Isolator version 7.4.2

CstProcessTemplatev1.xaml.txt (Build Process Template being used.)
answered by BretB (880 points)
0 votes
As an experiment I included TFSBuildServiceHost.exe in the exclude.dat file but the build error happened after doing that again today.
answered by BretB (880 points)
0 votes
Hi,

Thank you for the detailed reply.
It seems that running multiple builds in parallel may cause this issue.

Please check if it reproduces when there're 2 builds running under a single TFSBuildServiceHost.exe process.

Looking forward to your reply.
answered by alex (17k points)
0 votes
We had the same thought several days ago so we configured the build server to only run a single build agent. Unfortunately it did not eliminate the error from occurring.
answered by BretB (880 points)
0 votes
I have not heard anything for a few days. Any further suggestions?
answered by BretB (880 points)
0 votes
Hi,

Do you run tests with code coverage in the build?
answered by alex (17k points)
0 votes
Yes. We do. I will turn off "Code Coverage" and see if that makes a difference.
answered by BretB (880 points)
0 votes
Setting the window "Add/Edit Test Run" and field "Options" to "None", instead of "Enable Code Coverage", seems to have corrected and/or minimized the problem.

That will work for now, but in the future we may like to know what our test coverage is during each build. Is this something TypeMock can fix? If so, is there a fix scheduled for this?

Thank you.
answered by BretB (880 points)
0 votes
We're looking into it.
I'll update here as soon as progress
answered by alex (17k points)
...