3

I am having a problem with an MONO application, I'm trying to compile the project (with MonoDevelop) so as to load the library run mscorlib.dll 4.0 instead of version 2.0. (I need System.Type.op_Equality method that is in version 4.0 but not in 2.0).

I've temporarily solved by making a link:

# cd /usr/lib/mono/2.0
# mv mscorlib.dll mscorlib.dll.bak
# ln ../4.0/mscorlib.dll mscorlib.dll

But of course this is not a valid solution.

Does anyone know how to MONO load mscorlib 4.0 instead of 2.0?

Thanks and sorry for my English

gokuhs
  • 130
  • 11

2 Answers2

3

Finaly I found a solution for this problem:

https://bugs.launchpad.net/ubuntu/+source/gtk-sharp2/+bug/884035/comments/14

Simply modify the "app.config" file and change the content for this:

<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0"/></startup></configuration>

Recompile the proyect and now work fine.

gokuhs
  • 130
  • 11
1

Right-click the project -> open the Build/General page and make sure Target Framework is Mono / .NET 4.0:

enter image description here

Rolf Bjarne Kvinge
  • 19,253
  • 2
  • 42
  • 86
  • Thaks Rolf Bjarne, but now I have that configuration, and I'm still doing the same. http://jesusanchez.net/instantanea2.png – gokuhs Jun 04 '12 at 10:37
  • forgive my ignorance, but I do not know how to make monodevelop show me the buld output. Can you tell me how i show the output? – gokuhs Jun 04 '12 at 11:40
  • @gokuhs: in the menu View -> Pads -> Error List. Now click the "Build Output" button and rebuild your project. – Rolf Bjarne Kvinge Jun 04 '12 at 11:50
  • Thanks for your help @rolf-bjarne-kvinge, this is the build output: (is in spanish sorry) http://pastebin.com/hhtT6qfJ – gokuhs Jun 04 '12 at 12:28
  • @gokuhs: that's doing the right thing, it's building a 4.0 executable. Exactly which problem are you having at runtime (i.e. how do you determine that you're running on a 2.0 runtime)? – Rolf Bjarne Kvinge Jun 04 '12 at 16:05
  • Thanks for the reply, I know because if I run the app without doing the procedure I describe above (create a link to overwrite the mscorlib.dll 2.0 and point to the mscorlib.dll 4.0) the application gives me the following exception:"Method not found: 'System.Type.op_Equality'." I got the idea to create the link after reading this thread: http://monotouch.2284126.n4.nabble.com/System-MissingMethodException-Method-not-found-System-Type-op-Equality-td3770750.html (Now I realize that you too you remarked on it ;-) ) – gokuhs Jun 05 '12 at 06:22
  • Reading the excepcion I found this: Missing method System.Type::op_Equality(Type,Type) in assembly /usr/lib/mono/2.0/mscorlib.dll, referenced in assembly /usr/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll – gokuhs Jun 05 '12 at 07:03
  • try running this from a command line and pastebin the output: `MONO_LOG_LEVEL=debug MONO_LOG_MASK=asm mono --debug yourapp.exe` (all in one line) – Rolf Bjarne Kvinge Jun 05 '12 at 07:21
  • Wow Thanks for the command, I will be useful later! :-) this is de output: http://pastebin.com/tjUjGEr2 – gokuhs Jun 05 '12 at 07:35
  • This is very strange. Can you try these too: `monodis --assemblyref yourapp.exe` and `mono --version`? – Rolf Bjarne Kvinge Jun 05 '12 at 07:42
  • This is stranger and stranger, there is no reason mono should load the 2.0 corlib, yet it does :| What does this program print: http://pastebin.com/hRKWcBii if you compile and run it like this: `dmcs test.cs && mono test.exe`? – Rolf Bjarne Kvinge Jun 05 '12 at 08:11
  • mmmmm your example seems ok: http://pastebin.com/adbxDqaj Is it possible monodevelop are using the copiler of Mono 2.0 (gmcs) instead of 4.0 (dmcs)? EDIT: I write your line in my Main function, this is the output: http://pastebin.com/XJnMeivm – gokuhs Jun 05 '12 at 08:28
  • No, MonoDevelop is using dmcs (as you showed yourself here: http://pastebin.com/hhtT6qfJ). However it does look like you have an extra mscorlib.dll in your output directory, can you remove that file and run again from the command line (so MonoDevelop doesn't copy the file back again)? – Rolf Bjarne Kvinge Jun 05 '12 at 08:50
  • I'm afraid I have the same problem: http://pastebin.com/6PbQRRyA, Could it be that the project initially was a Visual Studio .NET Proyect? If nothing works, I will try to reinstall mono (purging the packages) – gokuhs Jun 05 '12 at 09:23
  • I don't believe it's a problem with mono, but instead with your project. What happens if you create a new project from scratch/template? Does that work as expected? – Rolf Bjarne Kvinge Jun 05 '12 at 09:32
  • Mmmm, yes if I create a new project it work fine, now I will try to create a new project and move the code form the old proyect to the new project. – gokuhs Jun 05 '12 at 09:38
  • I finished copying the project to a new one, and now work properly, thanks for your help! – gokuhs Jun 05 '12 at 12:02