Can you tell the compiler to turn off support for Err object?

  • Thread starter Thread starter Samuel R. Neff
  • Start date Start date
S

Samuel R. Neff

I came across this inside an exception handler today when reviewing
some of my code:

L_0010: call void
[Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError([mscorlib]System.Exception)
L_0015: call void
[Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectError()

This seems like a waiste of resources (admitedly very minor).

If the Err object is only availble when used with "On Error Goto"
(according to the docs at least) then why does the compiler fill the
object with structured exception handling (try/catch)?

If we're not using Err at all, can we tell the compiler to ignore it
and not make it available at all?

Thanks,

Sam
 
Samuel R. Neff said:
If the Err object is only availble when used with "On Error Goto"
(according to the docs at least) then why does the compiler fill the
object with structured exception handling (try/catch)?

That's an implementation detail.
If we're not using Err at all, can we tell the compiler to ignore it
and not make it available at all?

Maybe removing the reference to "Microsoft.VisualBasic.dll" helps.

"How to program Visual Basic without using Visual Basic?"
 
I don't think you can remove the reference to the Microsoft.VisualBasic.dll...

Nigel
 
Nigel Armstrong said:
I don't think you can remove the reference to the
Microsoft.VisualBasic.dll...

You are right... All you can do is removing the project-wide import for
'Microsoft.VisualBasic' in the project properties, so you cannot access
'Err' without qualifying it.
 
"Herfried K. Wagner [MVP]"
"How to program Visual Basic without using Visual Basic?"
When you have that book ready, may I than have a preview?

Cor
 
Cor Ligthert said:
When you have that book ready, may I than have a preview?

;-)

I think this book would be a bestseller ;-).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top