Main Site Documentation

Exception System.Exception - CLR_E_WRONG_TYPE (8)


#1

Our application(on Raptor) reported following exception:

From COM1 DEBUG output:

stringToSend: AT+CLCC

responseTimeout: 5000
maxTimeoutBetweenCharacters: 500
numOfReceivedBytes: 55

#### Exception System.Exception - CLR_E_WRONG_TYPE (8) ####
#### Message: 
#### System.Text.UTF8Encoding::GetChars [IP: 0000] ####
#### MTC2.SerialComm::SendWaitResp [IP: 003c] ####
#### MTC2.GSM::SendATCmdWaitRespAsString [IP: 0017] ####
#### MTC2.GSM::CheckCallStatus [IP: 0019] ####
#### MTC2.GSMThread::RegularActions [IP: 00bf] ####
#### MTC2.GSMThread::GsmWorkingThread [IP: 0105] ####
#### MTC2.PCCommThread::pcCommThread [IP: 004b] ####

Uncaught exception

Could you please explain me little bit exact reason of this exception?
Our application communicates through GSM modem(mainly SMSs and CSD data) and this exception was generated after approx. 12 hours of running.

When this uncaught exception was generated other task (LED task) was still running (LED flashes in certain interval as it should).
So does it also mean that uncaught exception just stops thread where the exception was generated and rest application can still run?


#2

@ mhstr - I believe that exception is thrown when there is invalid UTF8 data or the null byte in the buffer you are trying to convert. It’s hard to say unless we see the data that caused the exception.

When an exception is throw and not caught, I believe you are correct in that it stops the thread it was thrown on but not others.


#3

So is there any exact rules how CLR behaves if there is reported some uncaught exception?
Can we say that:

  1. if there is just application running in main() without any other tasks then this application is stopped and exception is reported.

  2. if there is complex application with more threads then exception stops only the task where the exception was generated and other tasks remain running.

If so is there any possibility to start that affected task again(e.g. from some other - still running - task)?


#4

@ mhstr - You could design a system which monitors all threads in the system using the members of the thread object. If you find one that has failed you can restart it based on your application’s needs.

Main itself is run on a thread that is not really different from any other thread. If it has an uncaught exception, it’ll stop as well.