Cannot Execute Single Steps using “Run Selected” due to mscorlib.dll Compile Error

Ranorex Spy, Recorder, and Studio.
Balash
Posts: 6
Joined: Fri May 31, 2019 5:32 pm

Cannot Execute Single Steps using “Run Selected” due to mscorlib.dll Compile Error

Post by Balash » Wed Mar 04, 2020 11:13 pm

I’m building a project in .Netframework 4.7.2 with various nuget packages installed. If I compline and run the entire test suite, the project compline and execute correctly. But when I attempt to execute a single step, using run selected, in a project I get the following compile error:

Code: Select all

Compile Error:An assembly with the same identity 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has already been imported. Try removing one of the duplicate references. - C:\Users\xxxx\Automation\xxx\xxx\bin\Release\CreatingLibrary.Runner.exe
I check the box “do not reference mscolib.dll” under compline option but that didn’t make a difference.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6036
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Cannot Execute Single Steps using “Run Selected” due to mscorlib.dll Compile Error

Post by odklizec » Thu Mar 05, 2020 12:30 pm

Hi,

It's most probably caused by one of the nuget packages? Have you tried what's suggested in the error...
Try removing one of the duplicate references
Eventually, try to remove individual packages (one by one) to find which one is causing this issue.

BTW, in case you are using multiple projects, make sure that all of them target the same .Net version (project Settings >> Compiling tab)!
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Balash
Posts: 6
Joined: Fri May 31, 2019 5:32 pm

Re: Cannot Execute Single Steps using “Run Selected” due to mscorlib.dll Compile Error

Post by Balash » Thu Mar 05, 2020 11:42 pm

Hi Pavel,

Thanks for your reply.
  • The project, in its entirety, complies and runs without a problem. So it appears that the main project file doesn't contain duplicate references. I'm assuming, a temperately project files is dynamically generated to facilitate the build of a module or a step. That's a generated file so I cannot modify or remove duplicate references from that file.
  • Why should all projects target the same .Net version as long as the specific version of the .Net framework is installed on the machine?
Regards,
Balash

Balash
Posts: 6
Joined: Fri May 31, 2019 5:32 pm

Re: Cannot Execute Single Steps using “Run Selected” due to mscorlib.dll Compile Error

Post by Balash » Fri Mar 06, 2020 3:37 am

I found, at least, a temporary fix.

The issue, as the error message indicated, was that mscorlib.dll gets referenced twice due to, what I assume, a bug in Ranorex. It took a while to figure where those references were.

mscorlib.dll gets referenced twice :
Once in
  • projectname].csproj
And then again in:
  • [projectname].rxsln (which is generated by Ranorex)
Under
Project --> Project options --> Compile [tab] there is checkbox that has the option:

Do not reference mscorlib.dll

This checkbox doesn’t seem to work. So the only option was to remove the reference from the mail project file by deleting:
<Reference Include="mscorlib" />

Regards,
B