I get a "System.NullReferenceException: the object reference is not set to the object instance." according to my version. I created an example application that mimics what's in my production code.
void Abc::LogService::Log(String^ message) { try { int ret = DoProcessing(message); Exception^ ex; if (ret == 0) { ex = gcnew ArgumentException("Processing done."); } else { ex = gcnew ArgumentNullException("message", "Null args"); } throw ex; } finally {
With the above code, it reports an exception: at Abc.LogService.Log(String message) in logservice.cpp:line 19 , which corresponds to the throw ex; statement throw ex; in code.
The MSIL in the release build for this feature looks like this:
.method public hidebysig instance void Log(string message) cil managed {
From the MSIL code, it shows that in statement IL_0028, it loads a null value and causes a throw in the following expression. The strange part is, this only happens if I have a try-finally block. Debugging builds above code works fine.
Does this sound like a bug in the VS2015 v140 kit?
source share