Exception being generated from .net RSACryptoServiceProvider.Enrypt method

168 views Asked by At

Every once in a while, at random times my software crashes due to a an exception with this message:

"Additional information: The runtime has encountered a fatal error. The address of the error was at 0x72938d57, on thread 0xe34. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

If there is a handler for this exception, the program may be safely continued."

It is begin generated from the .net RSACryptoServiceProvider.Encrypt method. To take a look at it refer to https://github.com/HadiModarres/MRelay/blob/master/ConsoleApplication9/EncryptedRelay.fs line 94

my question is why is this happening and what can I do to catch exceptions that are generated from unmanaged code like this

1

There are 1 answers

0
ildjarn On BEST ANSWER

Reposting from comment:

rsa.Encrypt is not thread-safe.