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?