Recently I looked at some coding at the web. I found some people use Microsoft.VisualBasic.CompilerServices.ProjectData.ProjectData
class in catch
block.
catch (Exception exception1)
{
//ProjectData.SetProjectError(exception1);
Console.WriteLine(exception1.ToString());
Console.WriteLine();
Console.WriteLine(sSQL);
//ProjectData.ClearProjectError();
}
I searched it on msdn that mentioned that this API supports the .NET Framework infrastructure and is not intended to be used directly from your code.
I am curious what reason people use it. Would you explain it to me?
My experience has been that this type of code use is found in c#/VB.NET projects that have been converted from VB6. When developing new c#/VB.NET solutions/projects, this practice should not be used.
Note: This technique can safely be replaced with proper exception handling that you would be used to seeing in other .NET solutions/projects.
This code is either emitted by a code conversion tool that converted VB code to C#, or resulted from decompiling an assembly that was originally created using VB.
I'm porting a VB project to Mono, and found out that the VB compiler injects these calls ProjectData.SetProjectError(exception)
and ProjectData.ClearProjectError()
in any catch block, and try to find a way to prevent the compiler from doing so because Mono doesn't implement the ProjectData
module. And found your question while doing my research!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With