0
我有一個視圖從WCF服務填充到局部視圖的問題。一切工作正常,模型包含必要的數據,但不知何故,它不斷收到此錯誤。我可以清楚地看到ProduktDto的價值,所以它不是零,但仍然是這樣。來自WCF服務的屬性值越來越System.ArgumentNullException說它是空的,當它不是
聽說過的錯誤可能是在ConnectionString所以我在這裏包含它:
<add name="SpelDatabasContainer" connectionString="metadata=res://*/SpelDatabas.csdl|res://*/SpelDatabas.ssdl|res://*/SpelDatabas.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=SpelAffarenDatabas;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
還沒有找到這個答案嚴重的谷歌搜索後。 下面是視圖的代碼:
@model List<SpelAffarWCF.ProduktDto>
<table class="table table-responsive">
<tr>
<th>Id</th>
<th>Namn</th>
<th>Beskrivning</th>
<th>Utgivningsår</th>
<th>MP</th>
<th>SP</th>
<th>Pris</th>
<th>Utgivare</th>
<th>Konsoler</th>
<th>Genres</th>
<th>Aktiv order antal</th>
</tr>
@foreach (var spel in Model)
{
<tr>
<td title="Spelets Id">@spel.Id</td>
<td title="Spelets jävla namn">@spel.Namn</td>
<td title="@spel.Beskrivning">För musen över mig..</td>
<td title="När det släpptes">@spel.Utgivningsår</td>
<td title="Multipläjer">@Html.CheckBox("checkboxMP", spel.Multiplayer)</td>
<td title="Singlpläjer">@Html.CheckBox("checkboxSP", spel.Singleplayer)</td>
<td title="Spelet kostar faktiskt såhär mycket">@spel.Pris</td>
<td title="Id: @spel.Utgivare.Id, Spel: @spel.Utgivare.Produkter.Count()">@Html.ActionLink(spel.Utgivare.Namn, "EditPublisher", new { id = spel.Utgivare.Id })</td>
@if (spel.Konsoler.Count() > 0)
{
<td>
@foreach (var konsol in spel.Konsoler)
{
<p class="cellEntity">@konsol.Namn</p>
}
</td>
}
else
{
<td>Ingen.</td>
}
@if (spel.Genres.Count() > 0)
{
<td>
@foreach (var genres in spel.Genres)
{
<p class="cellEntity">@genres.Namn</p>
}
</td>
}
else
{
<td>Ingen genre.</td>
}
@if (spel.SpelPerOrders.Count() > 0)
{
<td>
@foreach (var spelOrder in spel.SpelPerOrders)
{
<p class="cellEntity">Id: @spelOrder.OrderId, @spelOrder.Antal st</p>
}
</td>
}
else
{
<td>Finns inte i någon order.</td>
}
<td>
<input type="button" value="Lägg till i kundvagn" onclick="AddToCart(@spel.Id)" />
</td>
</tr>
}
</table>
如果'Model'不爲null,則它可能爲1.模型集合中的空對象或集合中的一個'spel'對象具有空'Konsoler'屬性。 – 2014-12-03 12:50:31
崩潰總是發生在@ spel.Pris,或者如果我刪除它,相應的位置到下一個屬性,所以它總是在第7個屬性崩潰...當調試時,我可以看到所有的屬性不爲空.. .. – 2014-12-03 13:02:13
這當然很奇怪......'spel.Utgivare'和'spel.Utgivare.Produkter'都是非空的? – 2014-12-03 13:25:40