Main Site Documentation

Why do I get MMP : error MMP0000: CLR_E_FAIL when building


#1

I’m trying to convert a library from the “normal” .net framework to a micro framework library. I replaced the pieces that are not available in the micro framework. When I try to build the library I get this:

Compile complete – 0 errors, 35 warnings
MMP : error MMP0000: CLR_E_FAIL

I found suggestions on the internet that say I have a problem in the metadata processor build step. However when I run the metadataprocessor from the command line I get no errors. Unfortunately vs2010 does not display the command it uses to run the metadataprocessor so my options might be different. I use v4.1 of the framework. Also the warnings are all about vrariables that are never used. Code cleanup will follow.

Anyone can tell me how to diagnose this.


#2

Maybe you have [,]? use [][] instead


#3

As far as I can find I replaced all multidimensional array’s with jagged array’s.

Are there any other known constructs the compiler or visual studio approves off that are not available in the .net micro framework? I tried a second library but it gives the same error. An new library project compiles fine though.


#4

Try recreating the library and add classes one at a time until you find the class that is giving you a problem.

You can then work on identifying the method with the problem.


#5

I found the file that contains the problem code. It seems to consist mostly of about 10000 lines of very large (case wise) switch statements. I’m trying to enable and disable parts of it to see what triggers the error, but I have not found anything consitant yet. Are there known limitations that have to do with code size and/or switch statements?


#6

Yes, there are known size limits per library. You can solve this by breaking it up into separate libs. I had the same issue with Pyxis 2.


#7

Is there any known overview of these limitations? For example what is the maximum library size? Are there limitations in the call stack? And what not more…

To give a little more info (can’t seem to include the project here). I’m trying to figure out if, for example the chipworkx system is capable enough to emulate an older microcontroller system. So I found a .net library on the net that contains a z80 cpu, It’s basicaly one big class written out in several files (partial classes). It’s fetch and execute is basicaly one huge switch statement. If I comment out enough of it, the lib compiles. Different amount of commented out parts yield different results. Because it’s an partial class setup it is all in all very difficult to split up and for the moment I can’t dream up a way to simplify the switch statement. would be easier if I knew what limit I am exceeding. It would realy be nice if the metadataprocessor gave a propper error message

btw. I realise that this type of application might be a little over ambitous for .netmf


#8

ChipworkX will handle what you’re asking for if you’re clever. I don’t remeber the limit size offhand but you can google it. It’s a Micro Framework limit not a board limit.


#9

I did a few google searches and must say that it seems difficult to me to get proper results without al lot of full .net results in the way. Found several posts refering to the max but none stating what it actually is! Most say it’s completely undocumented. The libraries giving problems are about 200 kb in size which is about double the largest .netmf lib I have seen. Guess I will just have to see if I’m clever enough to split the libs, eliminating all the circular dependencies.


#10

You will not find an exact number because IIRC there is no exact number, it is somewhat related to many variables internally to the assembly, to things that you can’t measure easily.

In general, these are small device with much less resources than PCs. It is extremely rare that someone would run into the limitation as programs running on these devices are usually simpler.


#11

I’d recommend starting a new project and copying over the functions one at a time. Be sure to be mindful of what you can throw into another library as you go. That’s the easiest way to beat the limit.

The largest library I have, Pyxis 2’s Kernel, is 150k.


#12

First of all, my thanks to everybody who took the time to reply to my question. Second I believe the limit I was reaching was not the maximum library size (at least not the only one). It seems that the .netmf does not accept switch statements with more then 256 cases in them. When i split the switch statements the error goes away.


#13

More that 256! Who is going yo debug this code? :slight_smile:


#14

[quote]More that 256! Who is going yo debug this code?
[/quote]

That is what I was thinking! Several years ago I wrote a parser for TI Calculator basic that was part of a PC based program editor I wrote. There was a open source code for parsing out at that time but it was awful with several page long switch statements. I would up creating a set of arrays that mapped each opcode to a function delegate (sort of like using function pointers) that could decode that opcode. The parser worked a line at a time and was re-entrant so it could walk through nested statements as well.

It could be that you could do something similar and wind up with much shorter and more understandable code.


#15

My guess is it’s generated code… a lexigraphical analyzer, or parser, or something…


#16

Jeff is actually quite close.

As stated in my previous replies I’m trying to do emulation of an older chip. I found some code on the internet that uses a large switch statement to process every opcode. It’s not pretty, but I could not think of any construct to replace it with. Jeff’s idea with array’s and delegates sound nice to try out. I do wonder what has the largest overhead / is the fastest to execute the switch or the array + function calls. I looked at several examples on the internet and most seem to use the switch method. Some even do nested switches based upon that fact that not every opcode can follow another.

Also to Gus: I realy hope to avoid debugging :D, but probably will not. The current code I got on the internet seems to debug bases on comparing the output to what it should be and that can be done opcode by opcode. Not easy to do but I does narrow things down. It’s a really basic cpu.


#17

Today I’ve faced an another case when CLR_E_FAIL occurs.
Described here - https://netmf.codeplex.com/workitem/2095
Hope this may help someone :slight_smile:


#18

Still relevant!