The assembly mscorlib.dll was not found or could not be loaded
Asked Answered
T

1

3

Firstly, I've seen this question, and while the problem seems similar, it is not the same.

I'm running a trimmed down mono, built without the 4.5 profile using ./configure --with-profile4=yes --with-profile4_5=no.

I have an application that targets .NET 4.0, built using mono's xbuild. When I run it against my trimmed down mono installation, I get this error:

The assembly mscorlib.dll was not found or could not be loaded. It should have been installed in the `/opt/my-app/mono/lib/mono/4.5/mscorlib.dll' directory.

Now, I'm not referencing only 4.0 assemblies - nothing from 4.5, AFAICS.

Why might I be getting this error?

I'm not sure if it's related, but I get this warning when building with xbuild (but not when building with msbuild, although I still get the mscorlib.dll when running against my trimmed down mono):

warning CS1685: The predefined type `System.Runtime.CompilerServices.ExtensionAttribute' is defined multiple times.
Using definition from `mscorlib.dll' 

I'm also not sure if this is relevant either, but the build machine does has .NET 4.5 installed.

Tamp answered 13/5, 2014 at 8:46 Comment(2)
You are building your app with the wrong reference assemblies, using the 4.5 version of them instead of the 4.0 version you need. The warning about ExtensionAttribute is highly relevant, it was moved in 4.5 from System.Core to mscorlib. Otherwise pretty unclear how this happened, maybe this "trimmed down" version is too trim.Evacuate
I've quadruple-checked, and I am targeting .NET 4.0 in the project, and all references to .NET DLLs are from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0. The only thing I've trimmed out of Mono at this stage is support for the 4.5 profile.Tamp
T
3

I figured it out - I needed to set MONO_PATH to:

/opt/my-app/mono/lib/mono/4.0:/opt/my-app/mono/lib/mono/3.5:/opt/my-app/mono/lib/mono/2.0:.

So I needed to tell it where to look for libraries; I had (wrongly) assumed that would be automatic based on the location of the mono executable.

Tamp answered 13/5, 2014 at 14:25 Comment(7)
For those experiencing this issue with the 3.4 release, see #22286330Fluster
@Fluster my issue was with 3.4.0. As per your answer, I was already re-creating the file missing from the tarball ans still got this errorTamp
Did you create the file correctly? In your comment on my anwser you said there was 'weirdness' in my echo command, but that's how the content of the file is supposed to look. I installed mono 3.4 on 4 servers just now, using the command from my answer, and it's working fine. So if you created the file correctly, that's very strange ;/Fluster
@Fluster See my comment - that's not how the content of the file is supposed to work! I guess you had some kind of copy and paste error pasting to SO, and the content of your actual file is correctTamp
I copied it from a different site (codeproject) which has it wrong I guess. Nevertheless, my installs all worked fine (until the wrong content becomes an issue ofc) so I don't get why yours is still missing 4.5Fluster
Mine is supposed to be missing 4.5 (--with-profile4_5=no). My issue was that I was getting this error with apps targeting 4.0Tamp
Right, I've been reading so many of these questions I got them mixed up. Anyway, I hope manually changing the path fixed the issue for you. Not sure if the offical installer does anything special.Fluster

© 2022 - 2024 — McMap. All rights reserved.