Welcome to Typemock Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!

Autodeploy of TypeMock 7.0 fails randomly on build machine

+1 vote
After upgrading to TypeMock 7.0 our build script fails to autodeploy/register TypeMock about 1/4 of the times. Rerunning the build fixes the issue, but it will fail again in a later build.

We autodeploy using the following msbuild script:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   
   <PropertyGroup>
      <TypeMockLocation>C:\BuildAgent\work\fbee78bdf3a3ba14\WorkingDir\SW\3rdParty\TypeMock\bin</TypeMockLocation>
   </PropertyGroup>
   <Import Project ="$(TypeMockLocation)\TypeMock.MSBuild.Tasks"/>

   <Target Name="RegisterTypeMock">
      <TypeMockRegister Company ="OurCompany" License="OurLicenseKey" AutoDeploy="True"/>
   </Target>

   <Target Name="StartTypeMock">
      <TypeMockStart/>
   </Target>

   <Target Name="UnRegisterTypeMock">
      <TypeMockStop UnDeploy="True"/>
   </Target>

</Project>

The error message when autodeploying is:
MockRegister.msbuild(8,10): error MSB4018: The "TypeMockRegister" task failed unexpectedly.
TypeMockRegister.msbuild(8,10): error MSB4018: System.OverflowException: Arithmetic operation resulted in an overflow.
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.Deploy.GACUtil.GetGACAssemblyPath(String assemblyName)
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.Deploy.AutoDeployTypeMock.RemoveGAC(Publish publisher, String assembly)
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.Deploy.AutoDeployTypeMock.DoGacInstall(Publish publisher, String interceptorsFilePath)
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.Deploy.AutoDeployTypeMock.Deploy(String rootDirectory)
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.CLI.Common.TypeMockRegisterInfo.Execute()
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.MSBuild.TypemockTaskBase.Execute()
TypeMockRegister.msbuild(8,10): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
TypeMockRegister.msbuild(8,10): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
TypeMockRegister.msbuild" (RegisterTypeMock target(s)) -- FAILED.
asked Mar 14, 2012 by halstein (2,170 points)

18 Answers

0 votes
Hi,

Thanks for the report, we are checking this out and I'll get back to you with an answer ASAP.
answered Mar 14, 2012 by ohad (37,080 points)
0 votes
Hi,
Sorry, I couldn't reproduce the error. Can you please post here the content of the directory:
C:\BuildAgent\work\fbee78bdf3a3ba14\WorkingDir\SW\3rdParty\TypeMock\bin
answered Mar 15, 2012 by ohad (37,080 points)
0 votes
I have the same issue. Any news about this? I'm using the 7.0.1 version.
answered Mar 20, 2012 by JK (720 points)
+2 votes
Hi,

We've just released 7.0.2 which contains a fix to this bug. it can be downloaded here.

Regards,
Elisha,
Typemock Support
answered Mar 20, 2012 by Elisha (22,740 points)
0 votes
Wow. That was fast :)

I can also verify that this new 7.0.2 fixed my problems.

Thanks!
answered Mar 20, 2012 by JK (720 points)
+1 vote
7.0.2 gave us a new autodeploy issue. Now we get this instead:
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.AppDomain.CreateInstance(String assemblyName, String typeName)
at System.EnterpriseServices.Internal.AssemblyManager.GetGacName(String fName)
at System.EnterpriseServices.Internal.Publish.GacRemove(String AssemblyPath)
at TypeMock.Deploy.AutoDeployTypeMock.RemoveGAC(Publish publisher, String assembly)
at TypeMock.Deploy.AutoDeployTypeMock.RemoveOldAssemblies(Publish publisher)
at TypeMock.Deploy.AutoDeployTypeMock.Deploy(String rootDirectory)
at TypeMock.CLI.Common.TypeMockRegisterInfo.Execute()
at TypeMock.MSBuild.TypemockTaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
at Microsoft.Build.BackEnd.TaskBuilder.InitializeAndExecuteTask(TaskLoggingContext taskLoggingContext, ItemBucket bucket, TaskHost taskHost, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteBucket(TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Dictionary`2 lookupHash)
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(TaskExecutionMode mode, Lookup lookup)
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(TargetLoggingContext loggingContext, BuildRequestEntry requestEntry, ITargetBuilderCallback targetBuilderCallback, ProjectTargetInstanceChild taskInstance, TaskExecutionMode mode, Lookup inferLookup, Lookup executeLookup)
at Microsoft.Build.BackEnd.TargetEntry.ProcessBucket(ITaskBuilder taskBuilder, TargetLoggingContext targetLoggingContext, TaskExecutionMode mode, Lookup lookupForInference, Lookup lookupForExecution)
at Microsoft.Build.BackEnd.TargetEntry.ExecuteTarget(ITaskBuilder taskBuilder, BuildRequestEntry requestEntry, ProjectLoggingContext projectLoggingContext)
at Microsoft.Build.BackEnd.TargetBuilder.ProcessTargetStack(ITaskBuilder taskBuilder)
at Microsoft.Build.BackEnd.TargetBuilder.BuildTargets(ProjectLoggingContext loggingContext, BuildRequestEntry entry, IRequestBuilderCallback callback, String[] targetNames, Lookup baseLookup)
at Microsoft.Build.BackEnd.RequestBuilder.BuildProject()


The machine has more than a gig free memory and looking at the task manager I cannot see that msbuild, typemock or any other process spike in memory usage when this happens. Maybe TypeMock tries to allocate some ridiculous amount all at once and gets rejected right away...

Using MSBuild 4.0 and the issue happens with both x86 and x64 versions of MSBuild.
answered Mar 23, 2012 by halstein (2,170 points)
0 votes
Hi,

We will look into it, and return when we have more information.
answered Mar 23, 2012 by yoel (1,900 points)
+1 vote
Updates:
7.0.3 has the same issue.
Auto deploying TypeMock seems to alternate between OutOfMemoryException, msbuild crashing imediately with no message or msbuild stuck forever doing nothing until it is manually killed.

7.0.1 works for now, with the original "The TypeMockRegister task failed unexpectedly" error sometimes happening.
answered Mar 26, 2012 by halstein (2,170 points)
0 votes
Still having problems with the 7.0.4 package. Here is the error message from our build server. After running the CI again might help or not. So it seems that the registration is not working properly yet.

Microsoft (R) Build Engine Version 2.0.50727.3053
[Microsoft .NET Framework, Version 2.0.50727.3625]
Copyright (C) Microsoft Corporation 2005. All rights reserved.

Target StartUnitTests:
    Target RegisterTypeMock:
        Typemock Isolator Auto Deployed, version 7.0.4.0
    Target RegisterNCover:
        regsvr32 /s "C:\Program Files\NCover\NCover.Lib.x86.dll"
    Target StartTests:
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018: The "TypeMockStart" task failed unexpectedly.
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018: System.InvalidOperationException: Unable to generate a temporary class (result=1).
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018: error CS0006: Metadata file '[clip]...\assembly\GAC_MSIL\Configuration\7.0.4.0__3dae460033b8d8e2\Configuration.dll' could not be found
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018: 
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace, String location, Evidence evidence)
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at System.Xml.Serialization.XmlSerializer..ctor(Type type, XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute root, String defaultNamespace, String location, Evidence evidence)
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at System.Xml.Serialization.XmlSerializer..ctor(Type type, Type[] extraTypes)
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at Configuration.ProfilersModel.LoadModel()
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at Configuration.ProfilersModel..ctor()
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at TypeMock.CLI.Common.TypeMockStartInfo.LinkProfiler()
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at TypeMock.CLI.Common.TypeMockStartInfo.Execute()
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at TypeMock.MSBuild.TypeMockStart.ExecuteInternal()
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at TypeMock.MSBuild.TypemockTaskBase.Execute()
        [clip]...\MsBuild.UnitTesting.xml(24,5): error MSB4018:    at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)



Another error case

Target RegisterTypeMock:
        [clip]...error MSB4018: The "TypeMockRegister" task failed unexpectedly.
        [clip]...error MSB4018: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
        [clip]...error MSB4018:    at System.AppDomainSetup.UpdateContextProperty(IntPtr fusionContext, String key, Object value)
        [clip]...error MSB4018:    at System.AppDomainSetup.SetupFusionContext(IntPtr fusionContext)
        [clip]...error MSB4018:    at System.AppDomain.SetupFusionStore(AppDomainSetup info)
        [clip]...error MSB4018:    at System.AppDomain.InternalRemotelySetupRemoteDomainHelper(Object[] args)
        [clip]...error MSB4018:    at System.Threading.Thread.CompleteCrossContextCallback(InternalCrossContextDelegate ftnToCall, Object[] args)
        [clip]...error MSB4018:    at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor)
        [clip]...error MSB4018:    at System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)
        [clip]...error MSB4018:    at System.EnterpriseServices.Internal.AssemblyManager.GetGacName(String fName)
        [clip]...error MSB4018:    at System.EnterpriseServices.Internal.Publish.GacRemove(String AssemblyPath)
        [clip]...error MSB4018:    at TypeMock.Deploy.AutoDeployTypeMock.RemoveGAC(Publish publisher, String assembly)
        [clip]...error MSB4018:    at TypeMock.Deploy.AutoDeployTypeMock.RemoveOldAssemblies(Publish publisher)
        [clip]...error MSB4018:    at TypeMock.Deploy.AutoDeployTypeMock.PublishDllsToGAC(String rootDirectory)
        [clip]...error MSB4018:    at TypeMock.Deploy.AutoDeployTypeMock.Deploy(String rootDirectory)
        [clip]...error MSB4018:    at TypeMock.CLI.Common.TypeMockRegisterInfo.Execute()
        [clip]...error MSB4018:    at TypeMock.MSBuild.TypeMockRegister.ExecuteInternal()
        [clip]...error MSB4018:    at TypeMock.MSBuild.TypemockTaskBase.Execute()
        [clip]...error MSB4018:    at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)

answered Apr 3, 2012 by JK (720 points)
0 votes
Hi,

Thanks for the report, since we can't reproduce the issue we are preparing a patch that will give us more info about the problem.
I'll send it to you as soon as it is ready.
answered Apr 3, 2012 by ohad (37,080 points)
...