简体   繁体   English

WCF服务中属性的值正在获取System.ArgumentNullException,说它为null,否则为null

[英]Value in property from WCF service is getting System.ArgumentNullException saying it is null, when it isn't

I have a issue with a view being populated from a WCF service into a partial view. 我将WCF服务中的视图填充到局部视图中时遇到问题。 Everything works just fine and the model contains the data necessary, but somehow it keeps getting this error. 一切正常,并且该模型包含必要的数据,但是以某种方式使其不断出现此错误。 I can clearly see the value for the ProduktDto so it isn't null at all, but still says it is. 我可以清楚地看到ProduktDto的值,因此它根本不是null,但仍然说是。

Have heard that the error could be in the connectionString so I include it here: 听说错误可能在connectionString中,所以我将其包括在这里:

 <add name="SpelDatabasContainer" connectionString="metadata=res://*/SpelDatabas.csdl|res://*/SpelDatabas.ssdl|res://*/SpelDatabas.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=SpelAffarenDatabas;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

Havent found the answer for this after serious googling. Havent经过严格的谷歌搜索后找到了答案。 Here is the code for the view: 这是该视图的代码:

@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>

The error indicates it's either the spel.Utgivare.Produkter.Count() or spel.Konsoler.Count() call; 该错误表明它是spel.Utgivare.Produkter.Count()spel.Konsoler.Count()调用; the parameter of the Linq Count extension method is named source . Linq Count扩展方法的参数名为source

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.ArgumentNullException: &#39;值不能为空参数名称:源&#39; - System.ArgumentNullException: 'value can't be null Parametre name: source' 没有参数时的WCF System.ArgumentNullException - WCF System.ArgumentNullException when there's no argument 找不到针对System.ArgumentNullException的修复:值不能为null - Can't find a fix for System.ArgumentNullException: Value cannot be null System.ArgumentNullException:&#39;值不能为null。&#39; - System.ArgumentNullException: 'Value cannot be null.' system.argumentnullexception值不能为null - system.argumentnullexception value cannot be null System.ArgumentNullException:值不能为null - System.ArgumentNullException: Value cannot be null 异常:System.ArgumentNullException:值不能是 null - Exception: System.ArgumentNullException: Value cannot be null System.ArgumentNullException:'值不能是 null 错误 - System.ArgumentNullException: 'Value cannot be null error Add-Migration异常:System.ArgumentNullException:值不能为null。 参数名称:属性 - Add-Migration exception: System.ArgumentNullException: Value cannot be null. Parameter name: property System.ArgumentNullException:&#39;值不能为null。 参数名称:键 - System.ArgumentNullException: 'Value cannot be null. Parameter name: key'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM