Problem with casting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Edgar Zavala

    Problem with casting

    Hi,

    We have an very strange error and i though you can help us to
    understand what is happening.

    First we have an interface defined as:

    ---code-begins
    Public Interface ILessonReadersD AO
    <... properties and methods here ...>
    End Interface
    ---code-ends

    Then we have different objects who implement that interface, and some
    classes who use that interfaces... particulary we have one method in
    one class defined as:

    ---code-begins
    Public Shared Function GenerateContent Template(ByVal lessionId As
    Long, ByVal sectionId As Long, ByVal slideId As Long, ByVal access As
    ILessonReadersD AO) As StringTemplate
    ---code-ends

    Now... the problem is with this code:

    ---code-begins
    Dim access As ILessonReadersD AO = new LessonReadersAD O()

    Dim sTemplate As StringTemplate =
    LessonContentBu ilder.GenerateC ontentTemplate( LessonId, SectionId,
    SlideId, access)
    ---code-ends

    This code compiles ok but from time to time we get the following
    message:
    Option Strict On disallows implicit conversions from
    'Lesson.ILesson ReadersDAO' to 'Lesson.ILesson ReadersDAO'.

    If we recompile it works, just happens from time to time.

    The VS IDE give us a hint to change 'access' to CType(access,
    ILessonReadersD AO), we changed it:

    ---code-begins
    Dim sTemplate As StringTemplate =
    LessonContentBu ilder.GenerateC ontentTemplate( LessonId, SectionId,
    SlideId, access)
    ---code-ends

    and we still have the same problem.

    I don't know if somebody has the same problem or knows what is
    happening here.

    We use .Net 2.0, VS 2005, the solution has C# and VB.Net projecs.

    Regards,
    Edgar Zavala.
  • Steve Gerrard

    #2
    Re: Problem with casting

    Edgar Zavala wrote:
    Option Strict On disallows implicit conversions from
    'Lesson.ILesson ReadersDAO' to 'Lesson.ILesson ReadersDAO'.
    >
    This message suggests to me that sometimes you are making a change that requires
    rebuilding the project. It is as if the compiler sees the pending new version of
    ILessonReadersD AO as a different type from the last built version of
    ILessonReadersD AO.

    If rebuilding fixes it every time, I would not worry about it. It happens.


    Comment

    • Edgar Zavala

      #3
      Re: Problem with casting

      On Jul 13, 7:46 pm, "Steve Gerrard" <mynameh...@com cast.netwrote:
      Edgar Zavala wrote:
      Option Strict On disallows implicit conversions from
      'Lesson.ILesson ReadersDAO' to 'Lesson.ILesson ReadersDAO'.
      >
      This message suggests to me that sometimes you are making a change that requires
      rebuilding the project. It is as if the compiler sees the pending new version of
      ILessonReadersD AO as a different type from the last built version of
      ILessonReadersD AO.
      >
      If rebuilding fixes it every time, I would not worry about it. It happens..
      Yes we can live with that, but is anoying and time consuming because
      requires a Rebuild, also ... the porblem seems to be the casting
      "Option Strict On disallows implicit conversions from
      'Lesson.ILesson ReadersDAO' to 'Lesson.ILesson ReadersDAO'.", we think
      this is the same class, there should be no implicit conversion.

      Regards,
      Edgar Zavala.

      Comment

      Working...