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.

Community
  • 1
  • 1
Cocowalla
  • 13,822
  • 6
  • 66
  • 112
  • 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. – Hans Passant May 13 '14 at 10:38
  • 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. – Cocowalla May 13 '14 at 11:03

1 Answers1

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.

Cocowalla
  • 13,822
  • 6
  • 66
  • 112
  • For those experiencing this issue with the 3.4 release, see http://stackoverflow.com/questions/22285830/linux-mono-installation-and-errors/23904603 – natli May 28 '14 at 07:01
  • @natli my issue was with 3.4.0. As per your [answer](http://stackoverflow.com/a/23904603/25758), I was already re-creating the file missing from the tarball ans still got this error – Cocowalla May 28 '14 at 08:14
  • 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 ;/ – natli May 28 '14 at 09:04
  • @natli 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 correct – Cocowalla May 28 '14 at 09:07
  • 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.5 – natli May 28 '14 at 10:28
  • 1
    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.0 – Cocowalla May 28 '14 at 12:46
  • 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. – natli May 28 '14 at 13:17