'HtmlTextWriter' cannot be converted to 'HtmlTextWriter'.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Blaz Ziherl

    #1

    'HtmlTextWriter' cannot be converted to 'HtmlTextWriter'.

    Hi,

    I am developing an application in VisualBasic .NET and got the
    following error:

    "An unhandled exception of type 'System.Invalid CastException' occurred
    in microsoft.visua lbasic.dll

    Additional information: Argument 1 to method 'Control.Render Control'
    has type 'HtmlTextWriter ' and cannot be converted to
    'HtmlTextWriter '."

    I am a newby to .NET, but this sounds a bit stupid to me. However, I
    am also posting problematic part of the code where the error occurs:

    Dim targetObj As New Object()
    Dim sw As New StringWriter()
    Dim tw As New System.Web.UI.H tmlTextWriter(s w)
    targetObj = a.CreateInstanc e(aT.FullName)
    targetObj.Rende rControl(tw) <--- here's the problem!
    MsgBox(sw.ToStr ing())

    Hopefuly someone will have an idea what's wrong.
    Blaz Ziherl
    blaz.ziherl@abr axas.si
  • Ed Kaim [MSFT]

    #2
    Re: 'HtmlTextWriter ' cannot be converted to 'HtmlTextWriter '.

    Where are you initializing a and aT? If aT doesn't point to a valid type it
    could be the problem.

    "Blaz Ziherl" <blaz.ziherl@ab raxas.si> wrote in message
    news:9d318fd9.0 401020408.5da6c 6a0@posting.goo gle.com...[color=blue]
    > Hi,
    >
    > I am developing an application in VisualBasic .NET and got the
    > following error:
    >
    > "An unhandled exception of type 'System.Invalid CastException' occurred
    > in microsoft.visua lbasic.dll
    >
    > Additional information: Argument 1 to method 'Control.Render Control'
    > has type 'HtmlTextWriter ' and cannot be converted to
    > 'HtmlTextWriter '."
    >
    > I am a newby to .NET, but this sounds a bit stupid to me. However, I
    > am also posting problematic part of the code where the error occurs:
    >
    > Dim targetObj As New Object()
    > Dim sw As New StringWriter()
    > Dim tw As New System.Web.UI.H tmlTextWriter(s w)
    > targetObj = a.CreateInstanc e(aT.FullName)
    > targetObj.Rende rControl(tw) <--- here's the problem!
    > MsgBox(sw.ToStr ing())
    >
    > Hopefuly someone will have an idea what's wrong.
    > Blaz Ziherl
    > blaz.ziherl@abr axas.si[/color]


    Comment

    • Blaz Ziherl

      #3
      Re: 'HtmlTextWriter ' cannot be converted to 'HtmlTextWriter '.

      Here's the declaration code for a and aT:

      Dim a As [Assembly] =
      [Assembly].LoadFrom("file ://c:/windows/microsoft.net/framework/v1.1.4322/system.web.dll" )

      Dim aTypes As Type() = a.GetTypes()
      Dim aT As Type
      For Each aT In aTypes
      ...
      Next

      I hope you will see any possible problems here...if not, I can post
      the whole code.

      Blaz


      "Ed Kaim [MSFT]" <edkaim@online. microsoft.com> wrote in message news:<uhYi$ue0D HA.2676@tk2msft ngp13.phx.gbl>. ..[color=blue]
      > Where are you initializing a and aT? If aT doesn't point to a valid type it
      > could be the problem.
      >
      > "Blaz Ziherl" <blaz.ziherl@ab raxas.si> wrote in message
      > news:9d318fd9.0 401020408.5da6c 6a0@posting.goo gle.com...[color=green]
      > > Hi,
      > >
      > > I am developing an application in VisualBasic .NET and got the
      > > following error:
      > >
      > > "An unhandled exception of type 'System.Invalid CastException' occurred
      > > in microsoft.visua lbasic.dll
      > >
      > > Additional information: Argument 1 to method 'Control.Render Control'
      > > has type 'HtmlTextWriter ' and cannot be converted to
      > > 'HtmlTextWriter '."
      > >
      > > I am a newby to .NET, but this sounds a bit stupid to me. However, I
      > > am also posting problematic part of the code where the error occurs:
      > >
      > > Dim targetObj As New Object()
      > > Dim sw As New StringWriter()
      > > Dim tw As New System.Web.UI.H tmlTextWriter(s w)
      > > targetObj = a.CreateInstanc e(aT.FullName)
      > > targetObj.Rende rControl(tw) <--- here's the problem!
      > > MsgBox(sw.ToStr ing())
      > >
      > > Hopefuly someone will have an idea what's wrong.
      > > Blaz Ziherl
      > > blaz.ziherl@abr axas.si[/color][/color]

      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: 'HtmlTextWriter ' cannot be converted to 'HtmlTextWriter '.

        Blaz Ziherl <blaz.ziherl@ab raxas.si> wrote:[color=blue]
        > Here's the declaration code for a and aT:
        >
        > Dim a As [Assembly] =
        > [Assembly].LoadFrom("file ://c:/windows/microsoft.net/
        > framework/v1.1.4322/system.web.dll" )
        >
        > Dim aTypes As Type() = a.GetTypes()
        > Dim aT As Type
        > For Each aT In aTypes
        > ...
        > Next[/color]

        Ah - in that case the problem is that you've got two different
        Assemblies loaded into your AppDomain - the one loaded automatically
        and the one you specifically loaded. It's essentially the same problem
        as the one explained here:

        Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.


        --
        Jon Skeet - <skeet@pobox.co m>
        Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

        If replying to the group, please do not mail me too

        Comment

        • Blaz Ziherl

          #5
          Re: 'HtmlTextWriter ' cannot be converted to 'HtmlTextWriter '.

          Aha, now at least I know what's the problem. But I am not quite sure I
          know how to solve it, LOL. Please note, that I am a .NET newby...so...

          Thanks, Blaz

          ps: I thought Microsoft came up with Visual Basic because they wanted
          to create an easy to use development tool......it's becoming
          everything but that, LOL! Visual Basic just ain't that basic anymore
          ;)

          Comment

          Working...