Last post Oct 23, 2006 08:21 PM by sschack
Apr 12, 2006 09:14 AM|rodneyjoyce|LINK
Apr 12, 2006 05:02 PM|sschack|LINK
We saw this back towards the end of Whidbey for a case where 1.1 DLLs were being used in an ASP.NET 2.0 app. Apparently the 1.1 compilers for C#/VB.NET had some boundary cases with the IL they emitted. In 2.0 there were low-level changes in the CLR that
made some 1.1 code unverifiable - which leads to the exception you are seeing. Unfortunately I can't claim to understand what it was the CLR changed - I just know we saw it.
In our specific case it was a problem with a C# switch statement that had more than 8 conditions - underneath the hood the C# compiler in 1.1 emitted IL code that became unverifiable in 2.0. I don't see any switch statements in your code above so that's
not going to be the specific problem.
To track down the problem, you should try the old fallback of chopping out all the code except the first line. Then run the app - see if it fails. Then uncomment the second line code code - run the app - see if it fails. Rinse and repeat. That's literally
how we tracked down the issues on our team.
Apr 12, 2006 08:03 PM|rodneyjoyce|LINK
Apr 12, 2006 09:37 PM|sschack|LINK
Heh - looks exactly like what was in our 1.1 assembly - a big switch statement. Our hack was to change the 1.1 code over to a bunch of if-then statements. Then we recompiled with VS2003, and were able to successfully use the updated assembly in a partial
trust ASP.NET 2.0 app.
Apr 13, 2006 08:20 AM|rodneyjoyce|LINK
Apr 13, 2006 09:48 AM|rodneyjoyce|LINK
Apr 13, 2006 04:58 PM|sschack|LINK
Is this custom control an ASP.NET 1.1 control? Just wondering because the line of code above works fine in a page on ASP.NET 2.0 running under Medium trust.
If you remove the line of code you have above, does the custom control work then?
I don't know why the line of code above would cause the problem - I don't understand the ins and outs of what makes IL verifiable versus not verifiable. As a long shot - what happens if you first construct the LiteralControl on one line - and then on the
next line call RenderControl(..)?
Apr 14, 2006 02:16 PM|rodneyjoyce|LINK
Apr 14, 2006 02:46 PM|rodneyjoyce|LINK
Apr 14, 2006 03:03 PM|sschack|LINK
Apr 14, 2006 06:15 PM|sschack|LINK
Turns out there was a low-level change to how the 2.0 Framework verifies code for a specific type of IL. And in some cases the older 1.1 compilers emit IL that is now considered unverifiable in 2.0. This was the response from the CLR gurus:
The Everett compiler emits the following code for the original 1.1 call:
IL_0012: call instance void [System.Web]System.Web.UI.Control::RenderControl(class [System.Web]System.Web.UI.HtmlTextWriter)
However RenderControl is a virtual method and due to the stricter requirements for ASP.NET 2.0, this is not considered a safe way to call a virtual method in Whidbey.
The code change that you made gets emitted as:
IL_0014: callvirt instance void [System.Web]System.Web.UI.Control::RenderControl(class [System.Web]System.Web.UI.HtmlTextWriter)
From a verification stanpoint, "callvirt" is safe - but "call" isn't.
Apr 15, 2006 05:02 AM|rodneyjoyce|LINK
Jun 07, 2006 04:45 PM|kantreddi|LINK
Oct 15, 2006 09:15 AM|pproducts|LINK
I have the same error when I want to Render a dataGrid.
For the problems mentioned in this thread, a tric did the job. I cannot find the tric for the dataGrid.
Thanks in advance... I have searched and struggled for days now, but nothing helps... do I have to wait for Delphi 200x, which fully support ASP.NET 2.0, or is there a tric for a dataGrid.Render...
Oct 16, 2006 02:31 PM|sschack|LINK
Oct 21, 2006 05:29 AM|pproducts|LINK
Thank you for your reply, I hope you can help.
Here is my sample code. The method dataGrid1.RenderControl(oHtmlTextWriter) is working fine under asp.net1.1 but the 'famous' error occurs under asp.net 2.0. Thank you very much in advance...
procedure tTest.Page_Load(sender: System.Object; e: System.EventArgs);
dt : datatable;
dr : datarow;
i : integer;
dc : datacolumn;
s : string;
r : double;
for i:=1 to 10 do
dr := i.ToString;
dr := 'Item ' + i.ToString();
r:=1.23 * (i + 1);
dv := dataview.Create(dt);
procedure TTest.Button1_Click(sender: System.Object; e: System.EventArgs);
i : integer;
oStringWriter : System.IO.StringWriter;
Response.AddHeader('Content-Disposition', 'attachment; filename=test.xls');
Response.Charset := '';
Oct 23, 2006 08:21 PM|sschack|LINK
I manually converted this into C#. The C# version runs without any errors, which leads me to think that the Delphi compiler is emitting IL that the .NET 2.0 Framework doesn't like. Just for reference I have pasted the converted version below:
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
private void FillGrid()
DataTable dt = new DataTable();
for (int i =0; i<10; i++)
dr = dt.NewRow();
dr = i.ToString();
dr = "Item " + i.ToString();
r = 1.23 * (i + 1);
dr =r.ToString(); //shortcut - this doesn't preserve the original formatting
DataView dv = new DataView(dt);
protected void Button1_Click(object sender, EventArgs e)
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment; filename=test.xls");
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.Charset = "";
oStringWriter = new System.IO.StringWriter();
oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);