MSBuild Error

Ask general questions here.
UgaAga
Posts: 69
Joined: Thu Mar 15, 2012 2:11 pm

MSBuild Error

Post by UgaAga » Thu Aug 23, 2012 3:41 pm

Hi,
it seems to me that there is a bug in the ranorex studio. If i create a new project which references to a com object and if i reference this project normally to another project, the solution will throw a MSBuild error while building. If i do the same things in visual studio everything works fine. You can reproduce this issue easily by creating a test suite solution, adding a second test suite, referencing a com object to the first test suite and referencing the first test suite to the second suite.

Thanks

Following the error output.

The "MSBuild" task failed unexpectedly.
Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: refCount should not be less than 1.
at Microsoft.Build.Shared.ErrorUtilities.ThrowInternalError(String message, Exception innerException, Object[] args)
at Microsoft.Build.Collections.CopyOnWriteDictionary`2.CopyOnWriteBackingDictionary`2.get_HasNoClones()
at Microsoft.Build.Collections.CopyOnWriteDictionary`2.set_Item(K key, V value)
at Microsoft.Build.Collections.CopyOnWriteDictionary`2.System.Collections.IDictionary.set_Item(Object key, Object value)
at Microsoft.Build.BuildEngine.BuildItem..ctor(String itemName, ITaskItem taskItem)
at Microsoft.Build.BuildEngine.TaskEngine.GatherTaskItemOutputs(Lookup lookup, TaskOutput taskOutputSpecification, String itemName, String propertyName, Object outputs)
at Microsoft.Build.BuildEngine.TaskEngine.GatherGeneratedTaskOutputs(Lookup lookup, TaskOutput taskOutputSpecification, String taskParameterName, String itemName, String propertyName, ITask task)
at Microsoft.Build.BuildEngine.TaskEngine.GatherTaskOutputs(TaskExecutionMode howToExecuteTask, ITask task, ItemBucket bucket)
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteBucket(EngineProxy engineProxy, ItemBucket bucket, Int32 bucketNumber, TaskExecutionMode howToExecuteTask)
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(TaskExecutionMode howToExecuteTask, Lookup lookup)
at Microsoft.Build.BuildEngine.TaskExecutionState.TaskEngineExecuteTask(TaskEngine taskEngine, TaskExecutionMode howTaskShouldBeExecuted, Lookup lookup)
at Microsoft.Build.BuildEngine.TaskExecutionState.ExecuteTask()
at Microsoft.Build.BuildEngine.TaskExecutionModule.ExecuteTask(TaskExecutionState taskState)
at Microsoft.Build.BuildEngine.TargetExecutionWrapper.SubmitNonIntrinsicTask(XmlElement taskNode, ITaskHost hostObject, ProjectBuildState buildContext)
at Microsoft.Build.BuildEngine.TargetExecutionWrapper.ExecuteCurrentTask(ProjectBuildState buildContext)
at Microsoft.Build.BuildEngine.TargetExecutionWrapper.ContinueRunningTasks(ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext, Boolean startingFirstTask)
at Microsoft.Build.BuildEngine.TargetExecutionWrapper.ContinueBuild(ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext)
at Microsoft.Build.BuildEngine.Project.ExecuteNextActionForProjectContext(ProjectBuildState buildContext, Boolean initialCall)
at Microsoft.Build.BuildEngine.Project.CalculateNextActionForProjectContext(ProjectBuildState buildContext)
at Microsoft.Build.BuildEngine.Project.ContinueBuild(ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext)
at Microsoft.Build.BuildEngine.Project.BuildInternal(BuildRequest buildRequest)
at Microsoft.Build.BuildEngine.Engine.BuildProjectInternalInitial(BuildRequest buildRequest, Project project)
at Microsoft.Build.BuildEngine.Engine.BuildProjectInternal(BuildRequest buildRequest, ProjectBuildState buildContext, TaskExecutionContext taskExecutionContext, Boolean initialCall)
at Microsoft.Build.BuildEngine.Engine.BuildProjectFileInternal(BuildRequest buildRequest)
at Microsoft.Build.BuildEngine.Engine.EngineBuildLoop(BuildRequest terminatingBuildRequest)
at Microsoft.Build.BuildEngine.TaskExecutionModule.BuildProjectFile(Int32 handleId, String[] projectFileNames, String[] targetNames, IDictionary[] globalPropertiesPerProject, IDictionary[] targetOutputsPerProject, EngineLoggingServices loggingServices, String[] toolsVersions, Boolean useResultsCache, Boolean unloadProjectsOnCompletion, BuildEventContext taskContext)
at Microsoft.Build.BuildEngine.EngineProxy.BuildProjectFilesInParallel(String[] projectFileNames, String[] targetNames, IDictionary[] globalProperties, IList`1[] removeGlobalProperties, String[] toolsVersions, Boolean returnTargetOutputs)
at Microsoft.Build.Tasks.MSBuild.ExecuteTargets(ITaskItem[] projects, Hashtable propertiesTable, String[] undefineProperties, ArrayList targetLists, Boolean stopOnFirstFailure, Boolean rebaseOutputs, IBuildEngine3 buildEngine, TaskLoggingHelper log, ArrayList targetOutputs, Boolean useResultsCache, Boolean unloadProjectsOnCompletion, String toolsVersion)
at Microsoft.Build.Tasks.MSBuild.BuildProjectsInParallel(Hashtable propertiesTable, String[] undefinePropertiesArray, ArrayList targetLists, Boolean success, Boolean[] skipProjects)
at Microsoft.Build.Tasks.MSBuild.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) (MSB4018)

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: MSBuild Error

Post by Support Team » Fri Aug 24, 2012 11:06 am

Hi,

please have a look at following forum post:
http://www.ranorex.com/forum/ranorex-3- ... t3457.html

Regards,
Tobias
Ranorex Team

UgaAga
Posts: 69
Joined: Thu Mar 15, 2012 2:11 pm

Re: MSBuild Error

Post by UgaAga » Fri Aug 24, 2012 11:35 am

Hi,
thanks for your reply. Sadly i don't think that the post can help me, although It seems to be the same error. Because i need to bind that library to my project. And secondly the whole project works in Visual Studio but not in Ranorex. So i hope you can fix this.

Thanks

UgaAga
Posts: 69
Joined: Thu Mar 15, 2012 2:11 pm

Re: MSBuild Error

Post by UgaAga » Fri Aug 24, 2012 11:37 am

The target framework of my project is 4.0, but the error still exists if i change the framework to 2.0 or 3.5. Furthermore the error doesn't appear in Visual Studio.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: MSBuild Error

Post by Support Team » Fri Aug 24, 2012 3:43 pm

Hi,

Which library do you mean?
Which VS and Ranorex version are you using?
Do you have installed the full/extended version of the .Net 4.0 framework?

Regards,
Markus
Ranorex Support Team

UgaAga
Posts: 69
Joined: Thu Mar 15, 2012 2:11 pm

Re: MSBuild Error

Post by UgaAga » Mon Aug 27, 2012 10:59 am

Hi,
thanks for your reply.
It's a COM library of our own. I'm using Ranorex 3.3.1, Visual Studio 2010 SP1 and the extended .Net 4.0 framework.

Ciao

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: MSBuild Error

Post by Support Team » Mon Aug 27, 2012 3:05 pm

Hello,

Do you have Code Contracts installed on your system?
If this is the case this could cause the problem.
Please read the following forum post to get more information: Problem starting to use Ranorex

Regards
Bernhard
Ranorex Support Team

UgaAga
Posts: 69
Joined: Thu Mar 15, 2012 2:11 pm

Re: MSBuild Error

Post by UgaAga » Tue Aug 28, 2012 11:38 am

Hi,
thanks for the tip, but that didn't help. I just created a little test project within i have referenced to the acrobat reader com object. If it fails because of the reference, just take another com object. Try to build the project in ranorex and in visual studio and you will see that it works in vs and not in ranorex.

Bye
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: MSBuild Error

Post by Support Team » Wed Aug 29, 2012 3:18 pm

Hello,

I added the Test\Test1\bin\Debug\Interop.Acrobat.dll to the References and tried to build the project in visual Studio and in Ranorex.
In both cases it worked without an error.
Please try to uninstall Ranorex completely and install it again. Please make sure that all prerequisites are installed properly. If you download the zip file from our download archive you will find the setup.exe file. You can also download the Ranorex-X.X.X.exe file to install Ranorex.
If you do so all necessary prerequisites will be installed.
Don't use the Ranorex-x.x.x.x.msi because then the prerequisites will not be installed.

Regards,
Bernhard
Ranorex Support Team

UgaAga
Posts: 69
Joined: Thu Mar 15, 2012 2:11 pm

Re: MSBuild Error

Post by UgaAga » Thu Aug 30, 2012 1:09 pm

Hi,
thanks for your reply, but you have to reference a COM object not the Interop dll! Open the solution and do the following:
- Expand Project Test1
- Right-click on References
- Choose "Add reference"
- Bring the COM tab into the view
- Select any reference (for example Adobe Acrobat 8.0 Type Library)
- Confirm and close the dialog
- Rebuild the solution

That should throw the error.

Kind regards

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: MSBuild Error

Post by Support Team » Fri Aug 31, 2012 3:05 pm

Hi,

Now I am able to reproduce the issue!
I will clarify this issue with our developer and get back to you as soon as possible.

Regards,
Bernhard
Ranorex Support Team

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: MSBuild Error

Post by Support Team » Tue Sep 04, 2012 8:52 am

Hello,

I looked once more into your project to found the cause of the error.
I saw that there was a reference named Test1 added to the "References" in project Test2. When you delete this reference and make 'Rebuild Solution' the build will finish without an error.

Regards,
Bernhard
Ranorex Support Team

UgaAga
Posts: 69
Joined: Thu Mar 15, 2012 2:11 pm

Re: MSBuild Error

Post by UgaAga » Tue Sep 04, 2012 10:03 am

Hi Bernhard,
thank you for your effort. Sadly i need the reference of Test1 in project Test2. Like i mentioned this works in Visual Studio, so it should work in Ranorex too, but it doesn't.

Bye

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: MSBuild Error

Post by Support Team » Tue Sep 04, 2012 3:25 pm

Hello,

I found a workaround for this problem.
You can use Tlbimp.exe to convert the COM library in a common language run time assembly and import the converted assembly into the project instead of the COM reference.
Further information about using Tlbimp.exe can be found on the msdn website Type Library Importer
It seems to be an issue in MSBuild which will be fixed in the new .NET version 4.5.

I hope this will help you.

Regards,
Bernhard
Ranorex Support Team

UgaAga
Posts: 69
Joined: Thu Mar 15, 2012 2:11 pm

Re: MSBuild Error

Post by UgaAga » Wed Sep 05, 2012 1:48 pm

Hi,
thank you that seems to be a nice workaround.
But i'm not sure if this is an issue of MSBuild because the project is buildable in Visual Studio!

Thank you