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

Ranorex Studio, Spy, Recorder, and Driver.
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: 7470
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

RazvanH
Posts: 1
Joined: Mon Sep 09, 2019 1:28 pm

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

Post by RazvanH » Fri Sep 18, 2020 9:59 am

Hi everyone,

I have the same problem here, I was able to solve it with @Balash's solution - by editing the * .csproj file.
Thanks for that Balash.

cslegna
Posts: 2
Joined: Fri Jun 26, 2020 9:04 pm

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

Post by cslegna » Tue Sep 29, 2020 8:51 pm

I ran into the same issue after importing a NuGet package for the first time, and I too was able to get around it by commenting out the reference to mscorlib in my .csproj (thanks Balash). Any word on a fix for this?

asisharavind
Posts: 6
Joined: Tue Aug 31, 2021 5:35 pm

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

Post by asisharavind » Thu May 12, 2022 6:40 pm

Can someone please help me on which .cs file needs to be changed. I mean the location of the file. I ran into the same issue.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
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 » Fri May 13, 2022 8:09 am

Hi,

Have you tried the steps from this post?
https://www.ranorex.info/cannot-execute ... tml#p59361
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

asisharavind
Posts: 6
Joined: Tue Aug 31, 2021 5:35 pm

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

Post by asisharavind » Fri May 13, 2022 4:17 pm

Yes i tried the below steps . But it is not working even after checking the box 'Do not reference mscorlib.dll'
Under
Project --> Project options --> Compile [tab]

Moreover i also tried to remove mscorlib from references folder and that also didn't help.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
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 » Mon May 16, 2022 7:00 am

Hi,

Have you physically checked .rxsln and .csproj files if the mscorlib reference is removed?
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

asisharavind
Posts: 6
Joined: Tue Aug 31, 2021 5:35 pm

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

Post by asisharavind » Thu May 19, 2022 7:44 pm

Yes thats right..And the error is displayed only when i'm trying to run a test case using the RUN CODE button (inside the test case). If I run the same test case from rxtst file, it runs successfully.

pattatha9
Posts: 2
Joined: Tue Aug 23, 2022 8:25 pm

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

Post by pattatha9 » Fri Aug 26, 2022 12:41 pm

I have the same problem here, I was able to solve it with @Balash's solution - by editing the * .csproj file.
19216811.bid
panoramacharter.ltd

Baxter
Posts: 11
Joined: Wed Jun 29, 2022 10:03 pm

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

Post by Baxter » Thu Sep 08, 2022 4:59 pm

This is definetly a bug with Ranorex. you can simply remove the reference in your project, which gets added automatically when you add certain nuget packages I guess ( i was adding system.data.sqlclient package):
You do not have the required permissions to view the files attached to this post.