Main Site Documentation

Clr_e_out_of_range mmp error


#1

I have little problem with my project on Cobra. Im try add one function for checking CRC on modbus(RS485) and when Im add it Im receive error:

Error	7	CLR_E_OUT_OF_RANGE	D:\YYY\Visual Studio 2010\Projects\XXX\XXX\XXX\MMP	XXX

If I comment function Project build normaly. I think that I don’t have any wrong thing in new function because Im have same problem few days ago in some other function and other class…
Here is modbus CRC function:


private void GetCRC(byte[] message, ref byte[] CRC)
            {
                //Function expects a modbus message of any length as well as a 2 byte CRC array in which to return the CRC values:
                ushort CRCFull = 0xFFFF;
                byte CRCHigh = 0xFF, CRCLow = 0xFF;
                char CRCLSB;

                for (int i = 0; i < (message.Length) - 2; i++)
                {
                    CRCFull = (ushort)(CRCFull ^ message[i]);
                    for (int j = 0; j < 8; j++)
                    {
                        CRCLSB = (char)(CRCFull & 0x0001);
                        CRCFull = (ushort)((CRCFull >> 1) & 0x7FFF);
                        if (CRCLSB == 1)
                            CRCFull = (ushort)(CRCFull ^ 0xA001);
                    }
                }
                CRC[1] = CRCHigh = (byte)((CRCFull >> 8) & 0xFF);
                CRC[0] = CRCLow = (byte)(CRCFull & 0xFF);
            }

when I comment function app build&deploy normaly and also size is not to big:


Assembly: Application (1.0.0.0) (5036 RAM - 863804 ROM - 20606 METADATA)


   AssemblyRef    =       72 bytes (      18 elements)

   TypeRef        =      592 bytes (     148 elements)

   FieldRef       =       92 bytes (      23 elements)

   MethodRef      =     1368 bytes (     342 elements)

   TypeDef        =      544 bytes (      68 elements)

   FieldDef       =      528 bytes (     264 elements)

   MethodDef      =     1136 bytes (     568 elements)



   Attributes      =        0 bytes (       0 elements)

   TypeSpec        =        8 bytes (       2 elements)

   Resources       =      712 bytes (      89 elements)

   Resources Files =        8 bytes (       1 elements)

   Resources Data  =   747683 bytes

   Strings         =    29256 bytes

   Signatures      =     3446 bytes

   ByteCode        =    65395 bytes

...
...
...

Total: (27656 RAM - 1103536 ROM - 128685 METADATA)


   AssemblyRef    =      300 bytes (      75 elements)

   TypeRef        =     2496 bytes (     624 elements)

   FieldRef       =      260 bytes (      65 elements)

   MethodRef      =     4268 bytes (    1067 elements)

   TypeDef        =     5800 bytes (     725 elements)

   FieldDef       =     3220 bytes (    1603 elements)

   MethodDef      =     8184 bytes (    4086 elements)



   DebuggingInfo  =     4112 bytes



   Attributes      =       48 bytes (       6 elements)

   TypeSpec        =       52 bytes (      13 elements)

   Resources Files =       96 bytes (       4 elements)

   Resources       =     1016 bytes (     127 elements)

   Resources Data  =   748867 bytes

   Strings         =    71988 bytes

   Signatures      =    18037 bytes

   ByteCode        =   149921 bytes

Any idea how to quick fix problem?


#2

Try to add the function but empty it.

There is assembly limit size. If you have some huge assembly then you may need to split it.


#3

If I add empty function is ok.
It stop failing for example if I remove some part from it(some for loop) or change from:


CRC[1] = CRCHigh = (byte)((CRCFull >> 8) & 0xFF);
CRC[0] = CRCLow = (byte)(CRCFull & 0xFF);

to:


CRC[1] = 0xFF;
CRC[0] = 0xFF;

Maybe is assembly limit reached because there is a lot of classes inside project:
-Network handling(LAN, WiFi, PPP and checking online status without NETMF blocking issue)
-Logging system(SD Card log system with file size limit)
-RS485 communication with device which use modbus protocol
-I/O module for handling I/O and their events
-LCD module for setup LCD settings for different size LCD’s
-RFID driver for authentication(Parallax RFID R/W module which can read password locked TAG data)
-Digital Temperature sensor
-Server communication(XML data exchange, loading crypted IFU files from server)
-IFU(decrypt files, check CRC and auto update device)
-TimeService(manual date time settings trough WEB interface OR NTP time update OR update time automatic when comunicate with remote server)
-WEBClient(Class which replace NETMF HttpWebRequest which is too slow)
-WEB Interface(Work over LAN) for changing settings on device.

And a lot of other things. So I must look carefully how I will split it into seperate assembly… What assembly limit do we have on EMX? Also what APP.HEX limit do we have on EMX(I know that last time when Im deploy 2,9MB app.HEX file has work ok)?


#4

Easy to find out. Put those lines of code back and remove some other function from somewhere else. If ti worked then you have reached the limits on one assembly


#5

GUS again thanks. Im make inside solution new project(Class Library) and move some drivers(RFID, Temp sensor) inside it and try uncoment CRC checking function. Project has build normaly so Im reach assembly limit. Now I must move another drivers inside this new assembly… Good thing is that I don’t need change anything in this classes except error logging. Before it is write direct to log class which is write data into queue and then into file(That I don’t receive strange access errors, corupted files or messy data inside error log) now this drivers raise exception event which in main class write to log class… So is quick fix :slight_smile: