Option strict

M

mp

Should that be on or off? (i know, dumb question)
I'd assume on, but then so many things break looks like it will take long
time to rewrite existing prog.
example:
Option Strict On disallows implicit conversions from 'Object' to
'Autodesk.AutoCAD.Interop.AcadApplication'.
but the variable wasn't declared as Object it was early bound
Private m_AcadApp As AcadApplication = Nothing

....then later

Private Function GetAutoCADInstance() As AcadApplication
Try
m_AcadApp =
Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
Catch ex As Exception
End Try
Return m_AcadApp
End Function



sorry but i don't see the implicit conversion

thanks for any info

mark
 
A

Armin Zingler

Am 25.04.2010 20:23, schrieb mp:
Should that be on or off? (i know, dumb question)
I'd assume on, but then so many things break looks like it will take long
time to rewrite existing prog.

Always fasten your seat belt. But AFAIK, here in Germany, taxi drivers
are allowed to drive without it if they are transporting a passenger.
So, this strict rule has an exception. Still I say: Always fasten seat belt.
example:
Option Strict On disallows implicit conversions from 'Object' to
'Autodesk.AutoCAD.Interop.AcadApplication'.
but the variable wasn't declared as Object it was early bound
Private m_AcadApp As AcadApplication = Nothing

....then later

Private Function GetAutoCADInstance() As AcadApplication
Try
m_AcadApp =
Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
Catch ex As Exception
End Try
Return m_AcadApp
End Function



sorry but i don't see the implicit conversion

What is the type of 'AcadApplication'? If it's 'Object', it could
be of any type. Did you consider this? Are you sure that 'AcadApplication'
will _always_ be of type Autodesk.AutoCAD.Interop.AcadApplication?
If you are, then cast the object to that type before the assignment.
 
M

mp

Armin Zingler said:
Am 25.04.2010 20:23, schrieb mp:

Always fasten your seat belt. But AFAIK, here in Germany, taxi drivers
are allowed to drive without it if they are transporting a passenger.
So, this strict rule has an exception. Still I say: Always fasten seat
belt.


What is the type of 'AcadApplication'? If it's 'Object', it could
be of any type. Did you consider this? Are you sure that 'AcadApplication'
will _always_ be of type Autodesk.AutoCAD.Interop.AcadApplication?
If you are, then cast the object to that type before the assignment.

oh, i think i see what you mean...
i should have had
Private m_AcadApp as
Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication = Nothing
instead of...
Private m_AcadApp As AcadApplication = Nothing
....is that what you mean?
thanks
mark
 
H

Herfried K. Wagner [MVP]

Am 25.04.2010 22:38, schrieb mp:
oh, i think i see what you mean...
i should have had
Private m_AcadApp as
Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication = Nothing
instead of...
Private m_AcadApp As AcadApplication = Nothing
...is that what you mean?

Not really.

The type of the
'Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication'
property (as I assume) should not be 'Object'. However, maybe this is
out of your control. In this case, read the documentation on the
property carefully. Maybe a cast ('DirectCast') is required to cast the
returned value to 'AcadApplication'.
 
M

mp

Herfried K. Wagner said:
Am 25.04.2010 22:38, schrieb mp:

Not really.

The type of the
'Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication'
property (as I assume) should not be 'Object'. However, maybe this is out
of your control. In this case, read the documentation on the property
carefully. Maybe a cast ('DirectCast') is required to cast the returned
value to 'AcadApplication'.

Thanks, I'll check it out
mark
 

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

Top