Home All Groups Group Topic Archive Search About
Author
25 Apr 2010 6:23 PM
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

Author
25 Apr 2010 6:58 PM
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.

Show quoteHide quote
> 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.


--
Armin
Author
25 Apr 2010 8:38 PM
mp
Show quote Hide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:e$uv7lK5KHA.4740@TK2MSFTNGP06.phx.gbl...
> 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
>> v>>
>> ....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.
>
>
> --
> Armin

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
Author
25 Apr 2010 9:41 PM
Herfried K. Wagner [MVP]
Am 25.04.2010 22:38, schrieb mp:
Show quoteHide quote
>>> 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
>>> v>>
>>> ....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.
>>
>>
>> --
>> Armin
>
> 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 S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
26 Apr 2010 3:57 AM
mp
Show quote Hide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:%23jZ4PAM5KHA.1888@TK2MSFTNGP05.phx.gbl...
> Am 25.04.2010 22:38, schrieb mp:
>>>> 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
>>>> v>>
>>>> ....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.
>>>
>>>
>>> --
>>> Armin
>>
>> 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 S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>

Thanks, I'll check it out
mark