4

Running ASP.NET 3.5 on Mono 2.6.7 (Debian), AjaxControlToolkit throws the following exception on startup: "Cannot cast from source type to destination type." (see stack trace below) This is a simple website referencing AjaxControlToolkit (so long as it's referenced, it will fail throwing this exception).

On .NET 3.5, the same simple webpage referencing AjaxControlToolkit.dll would run fine.

How would you get this to run on Mono?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
...

System.InvalidCastException: Cannot cast from source type to destination type.
  at System.Web.UI.ScriptManager.GetCurrent (System.Web.UI.Page page) [0x00000] in <filename unknown>:0 
  at AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences (System.Web.UI.Control control) [0x00000] in <filename unknown>:0 
  at AjaxControlToolkit.ExtenderControlBase.OnLoad (System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.LoadRecursive () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.LoadRecursive () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.LoadRecursive () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.LoadRecursive () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.LoadRecursive () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.LoadRecursive () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.LoadRecursive () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.ProcessLoad () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.ProcessPostData () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0 

Version information: Mono Runtime Version: 2.6.7 Debian 2.6.7-3ubuntu1); ASP.NET Version: 2.0.50727.1433

Zach Saw
  • 4,308
  • 3
  • 33
  • 49
Arash N
  • 324
  • 1
  • 2
  • 10
  • What is the problem? How to fix it? – Arash N Feb 03 '11 at 02:40
  • 1
    The problem, given the limited information available, is that your source type is different to your destination type. The answer is to make them the same type. – Joe Feb 03 '11 at 02:50
  • I'm running the same version on a Windows machine, but I'm having problems running it on a linux box with Mono installed. simple projects work, but this one gives me this error. I fixed a lot of assembly errors to get here. I don't know where to go from here. Apache log file shows no errors!!!! – Arash N Feb 03 '11 at 02:59
  • 4
    Why is this question closed? This problem is due to AjaxControltoolkit.dll referencing a different version of System.Web.Extensions than that of the web.config. Mono loads both versions and it causes conflicts when doing a cast (internally in AjaxControlToolkit.dll). The fix is to recompile AjaxControlToolkit from source and have it referenced against System.Web.Extensions v3.5.0.0. – Zach Saw May 16 '12 at 00:56
  • I'm having the same problem. I think you solved the problem but I don't know how. Would be more specific on "The fix is to recompile AjaxControlToolkit from source and have it referenced against System.Web.Extensions v3.5.0.0." I don't know why this question is closed... – Seehyung Lee Apr 12 '13 at 01:13

0 Answers0