20050530 pgsql mono System.InvalidCastException

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
6/3/2005 5:57:29 AM
Gravatar
Total Posts 36

Re: 20050530 pgsql mono System.InvalidCastException

With either 20050530 or svn of mojoportal when run with pgsql on debian unstable with latest mono and xsp svn I get the following exception and stack trace

System.InvalidCastException: Cannot cast from source type to destination type.
in <0x002e0> System.Web.HttpUtility:HtmlDecode (System.String s)
in <0x0000a> System.Web.HttpServerUtility:HtmlDecode (System.String s)
in <0x0009c> mojoPortal.Web.HtmlModule:ShowSingleItem ()
in <0x00255> mojoPortal.Web.HtmlModule:Page_Load (System.Object sender, System.EventArgs e)
in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs)
in <0x00056> System.Web.UI.Control:OnLoad (System.EventArgs e)
in <0x00026> System.Web.UI.Control:LoadRecursive ()
in <0x00083> System.Web.UI.Control:LoadRecursive ()
in <0x00083> System.Web.UI.Control:LoadRecursive ()
in <0x00083> System.Web.UI.Control:LoadRecursive ()
in <0x00083> System.Web.UI.Control:LoadRecursive ()
in <0x00083> System.Web.UI.Control:LoadRecursive ()
in <0x00149> System.Web.UI.Page:InternalProcessRequest ()
in <0x000a6> System.Web.UI.Page:ProcessRequest (System.Web.HttpContext context)
in <0x00233> System.Web.HttpApplication+ExecuteHandlerState:Execute ()
in <0x0007c> System.Web.HttpApplication+StateMachine:ExecuteState (IStateHandler state, System.Boolean readysync)


Everything works fine from IIS and the same db backend.

Mono SVN
XSP SVN
Debian unstable 2.6.10-1-686
6/3/2005 1:44:21 PM
Gravatar
Total Posts 18439

Re: 20050530 pgsql mono System.InvalidCastException

Hmm, this could be a bug in the latest svn of mono. I'm running one that is several weeks old using mojoportal 20050530 and pgsql and not experiencing this.

I don't see how it could have anything to do with the data layer. It looks like the error is happening in System.We.HttpUtility.HtmlDecode(String s) and its acting like no string is passed but it is not possible that the mojoportal code is passing anything other than a string

the error occurs in Web/Modules/HtmlModule.ascx.cs in this snip:
HtmlContent html = new HtmlContent(ModuleID);
??? ??? ??? if(html.Body.Length > 0)
??? ??? ??? {
??? ?? ?? ?? ?? // this is the offending line
??? ??? ??? ??? tdHtmlHolder.Controls.Add(new LiteralControl(Server.HtmlDecode(html.Body)));


??? ??? ??? }

note that in the HtmlContent class the Body is not only defined as a string but also initialized to an empty string and before making the call to Server.HtmlDecode we are checking the length of the string and it is greater than 0 so at this point you already have data from the database.

You may want to try commenting out that line in mojoportal and seeing if you get past this error. Maybe if you get mono and xsp again from svn it will be fixed. I will try the latest svn of mono myself tomorrow and see if it breaks my test site. If we determine this is a bug in mono it should be easy to make a test case to submit with the bug report.

Are you just using xsp? I am using mod_mono under apache but I doubt that makes a difference, mojoportal has always run fine under xsp.

You might also try making a simple aspx page and see if it works using something like

string test = Server.HtmlDecode("Hello Html");

if that causes an error it has to be a regression in mono

Keep me posted if you find any more info and I'll post again tomorrow after I have time to try some things.

Thanks,

Joe
6/3/2005 11:22:33 PM
Gravatar
Total Posts 36

Re: 20050530 pgsql mono System.InvalidCastException

I'm running under XSP not mod_mono, though I suspect that shouldn't matter as the code base is shared.

I get the same error running XSP (allbeit ancient 1.0.5) under mono 1.1.6 (current debian unstable)

I inlined your suggested test case on a page and it ran as expected without any errors. I will test with removing the line in a few hours.
6/4/2005 4:59:05 AM
Gravatar
Total Posts 18439

Re: 20050530 pgsql mono System.InvalidCastException

Ok if the test didn't cause an error I'm thinking it must be something about the content coming from the db that it doesn't like. Is your postgre sql db codepage using unicode or some other encoding? Are you using any different culture settings (than en-US) in the web.config or on your machine in general?

You might also try changing this:

tdHtmlHolder.Controls.Add(new LiteralControl(Server.HtmlDecode(html.Body)));

to

tdHtmlHolder.Controls.Add(new LiteralControl(html.Body));

and see what happens


6/5/2005 5:37:07 AM
Gravatar
Total Posts 18439

Re: 20050530 pgsql mono System.InvalidCastException

I think I found a problem in the release files, its a case sensitivity bug. Rename /Controls/ChildPageBreadCrumbs.ascx to /Controls/ChildPageBreadcrumbs.ascx and that should fix it.

This is not what your error message indicates but make sure it is named right just in case its giving the wrong error. IIS is not case sensitive so that would explain why it works ok there.


Joe
6/5/2005 9:04:48 AM
Gravatar
Total Posts 36

Re: 20050530 pgsql mono System.InvalidCastException

yes, I saw that with the release, I remedied that right quick. But that is also why I tried svn, both had the same result with the cast. I haven't tried commenting out that part just yet.
6/6/2005 8:00:45 AM
Gravatar
Total Posts 36

Re: 20050530 pgsql mono System.InvalidCastException

Removing the Server.HtmlDecode solved the issue, it now works under XSP svn and Mono svn

also on a side note your source package for the 20050530 release is missing ChildPageBreadcrumbs and ChildPageMenu (ascx cs and resx)
6/6/2005 8:42:57 AM
Gravatar
Total Posts 36

Re: 20050530 pgsql mono System.InvalidCastException

http://svn.myrealbox.com/viewcvs/trunk/mcs/class/System.Web/System.Web/HttpUtility.cs?rev=45317&r1=45316&r2=45317

may or may not be the culprit, going to try and revert just that file
6/6/2005 8:50:58 AM
Gravatar
Total Posts 36

Re: 20050530 pgsql mono System.InvalidCastException

After reverting that file, the issue is gone. going to look for any obvious mistakes in the current version and report on bugzilla.
6/6/2005 9:42:42 AM
Gravatar
Total Posts 36

Re: 20050530 pgsql mono System.InvalidCastException

spoke with gonzalo on irc, the fix has been committed to svn

For anyone else having this you need to edit
mcs/class/System.Web/System.Web/HttpUtility.cs line 776

key = (string) Entities [key.Substring (1, key.Length - 2)];
should be
key = Entities [key.Substring (1, key.Length - 2)].ToString();
6/6/2005 1:46:22 PM
Gravatar
Total Posts 18439

Re: 20050530 pgsql mono System.InvalidCastException

I had a feeling that was going to turn out to be a mono bug. Glad you got it fixed for the rest of us so I won't get that error when I update mono from svn.

Thanks!

Joe
You must sign in to post in the forums. This thread is closed to new posts.