473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

'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.InvalidCastException' occurred
in microsoft.visualbasic.dll

Additional information: Argument 1 to method 'Control.RenderControl'
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.HtmlTextWriter(sw)
targetObj = a.CreateInstance(aT.FullName)
targetObj.RenderControl(tw) <--- here's the problem!
MsgBox(sw.ToString())

Hopefuly someone will have an idea what's wrong.
Blaz Ziherl
bl*********@abraxas.si
Jul 21 '05 #1
4 1856
Where are you initializing a and aT? If aT doesn't point to a valid type it
could be the problem.

"Blaz Ziherl" <bl*********@abraxas.si> wrote in message
news:9d**************************@posting.google.c om...
Hi,

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

"An unhandled exception of type 'System.InvalidCastException' occurred
in microsoft.visualbasic.dll

Additional information: Argument 1 to method 'Control.RenderControl'
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.HtmlTextWriter(sw)
targetObj = a.CreateInstance(aT.FullName)
targetObj.RenderControl(tw) <--- here's the problem!
MsgBox(sw.ToString())

Hopefuly someone will have an idea what's wrong.
Blaz Ziherl
bl*********@abraxas.si

Jul 21 '05 #2
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]" <ed****@online.microsoft.com> wrote in message news:<uh**************@tk2msftngp13.phx.gbl>...
Where are you initializing a and aT? If aT doesn't point to a valid type it
could be the problem.

"Blaz Ziherl" <bl*********@abraxas.si> wrote in message
news:9d**************************@posting.google.c om...
Hi,

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

"An unhandled exception of type 'System.InvalidCastException' occurred
in microsoft.visualbasic.dll

Additional information: Argument 1 to method 'Control.RenderControl'
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.HtmlTextWriter(sw)
targetObj = a.CreateInstance(aT.FullName)
targetObj.RenderControl(tw) <--- here's the problem!
MsgBox(sw.ToString())

Hopefuly someone will have an idea what's wrong.
Blaz Ziherl
bl*********@abraxas.si

Jul 21 '05 #3
Blaz Ziherl <bl*********@abraxas.si> wrote:
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


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:

http://www.pobox.com/~skeet/csharp/plugin.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
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
;)
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
1
by: Rudy Ko | last post by:
Hi, All: I'm populating database records into a panel controls and want to render that panel into a HtmlTextWriter which will creating a word document. Do you know how to insert a page break...
3
by: Lee Chapman | last post by:
Hi, I want my ASP.NET web application to use a custom HtmlTextWriter. i.e. I want the object that the Framework passes to System.Web.UI.Control.Render() to be my own object, MyHtmlTextWriter,...
4
by: Barry | last post by:
object type cannot be converted to target type - i am getting this error message occuring numerous times in my task list, my project compiles and runs ok but it is a nuisance, I think Ihva eheard of...
4
by: Blaz Ziherl | last post by:
Hi, I am developing an application in VisualBasic .NET and got the following error: "An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll ...
2
by: larryvan | last post by:
I have been beating my head against a wall for two days now. I need to output a hyperlink using htmltextwriter.write that looks like this: <a...
4
by: James Page | last post by:
I can't seem to get HtmlTextWriter / renderControl to work for sending a control (html) in an e-mail messsage (VB.NET). Keeps telling me that control needs to be in a form tag with runat server...
2
by: rodchar | last post by:
hey all, can someone please show me how to write this to a stringbuilder using the htmltextwriter: <ul><li>test</li></ul> thanks, rodchar
3
by: =?Utf-8?B?cndvb2RydWY=?= | last post by:
Hello All, I am using an HtmlTextWriter to writer out some html. Prior to sending the content to the text writer, HttpUtility.HtmlEncode the string. However, doing so results in a string where...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.