PDA

View Full Version : [CLOSED] Keep receiving the following exception "An item with the same key has already been added."



Timothy
May 03, 2012, 12:39 PM
Hello,

When using the following example, I keep receiving the following exception:



An item with the same key has already been added.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.


Exception Details: System.ArgumentException: An item with the same key has already been added.


Source Error:


Line 80: new public static string Transform(string text)
Line 81: {
Line 82: return new ExtNetTransformer(ExtNetTransformer.PrepareText(te xt)).Transform();
Line 83: }
Line 84:




Source File: D:\Application\Library\Required Dependencies\Ext.NET\Source\2.0.0.DP1\Ext.Net\Core \ExtNetTransformer.cs Line: 82


Stack Trace:


[ArgumentException: An item with the same key has already been added.]
System.Collections.Generic.Dictionary`2.Insert(TKe y key, TValue value, Boolean add) +12674096
Transformer.NET.Token.ParseAnchors() +478
Transformer.NET.TextTransformer.Parse(List`1 tokensType, Dictionary`2 variables) +793
Transformer.NET.TextTransformer.Transform(List`1 tokensType, Dictionary`2 variables) +22
Ext.Net.ExtNetTransformer.Transform(String text) in D:\Application\Library\Required Dependencies\Ext.NET\Source\2.0.0.DP1\Ext.Net\Core \ExtNetTransformer.cs:82
Ext.Net.InitScriptFilter.Transform() in D:\Application\Library\Required Dependencies\Ext.NET\Source\2.0.0.DP1\Ext.Net\Core \InitScriptFilter.cs:70
Ext.Net.InitScriptFilter.Flush() in D:\Application\Library\Required Dependencies\Ext.NET\Source\2.0.0.DP1\Ext.Net\Core \InitScriptFilter.cs:57
System.Web.HttpWriter.Filter(Boolean finalFiltering) +398
System.Web.HttpResponse.FilterOutput() +141
System.Web.CallFilterExecutionStep.System.Web.Http Application.IExecutionStep.Execute() +168
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +270


When using the following:

Layout.cshtml:


<!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">
<title>@ViewBag.Title</title>
</head>
<body>
@(Html.X().ResourceManager()
.IDMode(Ext.Net.IDMode.Static)
.Theme(Ext.Net.Theme.Gray)
)


@(Html.X().Viewport()
.Border(false)
.Layout(Ext.Net.LayoutType.Fit)
.Items(a =>
a.Add(Html.X().Panel()
.BodyStyle("background-color: #FFFFFF;")
.Border(false)
.Layout(Ext.Net.LayoutType.Border)
.Items(b =>
{
b.Add(Html.X().Panel()
.BodyCls("x-panel-fade")
.Border(false)
.ItemsFromSection(this, "Content")
.Region(Ext.Net.Region.Center)
);
} )
)
)
)
</body>
</html>


Index.cshtml:


@{
ViewBag.Title = "Title";
Layout = "~/Areas/Management/Views/Shared/Layout.cshtml";
}
@section Content {
@(Html.X().Panel()
.Border(false)
.Padding(15)
.Items(a =>
{
a.Add(Html.X().Container()
.Html(@"
<h1>Setup</h1>
<p>Welcome to the Setup</p>
<br>
")
);
} )
)
}


It will only work when I change it to the following:



a.Add(Html.X().Container()
.ID("Welcome")
.Html(@"
<h1>Setup</h1>
<p>Welcome to the Setup</p>
<br>
")
);


I don't want to have to define an ID for everything :(

Can this be looked at? I'm using DP1.

Cheers,
Timothy

Daniil
May 03, 2012, 3:07 PM
Hi Timothy,

I've tested your code with the latest sources and it appears to be working without any errors.

We don't support DP1 anymore, so, please update from SVN. There was a lot of fixed bug since DP1.

Timothy
May 03, 2012, 3:12 PM
Confirmed, please close.

Cheers,
Timothy