“System.NotSupportedException”類型的未經處理的異常在 Microsoft.Data.Services.Client.dll 中發生
其他信息: 對此 POST 請求的響應未包含“location”標頭。此客戶端不支持這種做法。
未處理System.NotSupportedException
HResult=-2146233067
Message=對此 POST 請求的響應未包含“location”標頭。此客戶端不支持這種做法。
Source=Microsoft.Data.Services.Client
StackTrace:
在 System.Data.Services.Client.BaseSaveResult.HandleOperationResponseHeaders(HttpStatusCode statusCode, HeaderCollection headers)
在 System.Data.Services.Client.SaveResult.CreateNextChange()
在 System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
在 Quick.Framework.Site.Common.OData.ODataContextClient.Add[TBizModel](TBizModel[] entities) 位置 d:\Set working folder\Quick.Framework\Quick.Framework.Site.Common\OData\ODataContextClient.cs:行號 59
在 EbcBuy.Bll.Orders.UnitTest.OrderODataClientTest.OrderCommentsWebApiODataTest(ODataContextClient orderClient) 位置 d:\Set working folder\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.UnitTest\OrderODataClientTest.cs:行號 43
在 EbcBuy.Bll.Orders.UnitTest.OrderODataClientTest.Test() 位置 d:\Set working folder\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.UnitTest\OrderODataClientTest.cs:行號 34
在 EbcBuy.Bll.Orders.UnitTest.Program.Main(String[] args) 位置 d:\Set working folder\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.UnitTest\Program.cs:行號 20
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
===================================================
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<m:error xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n <m:code />\r\n <m:message xml:lang=\"en-US\">出現錯誤。</m:message>\r\n <m:innererror>\r\n <m:message>序列包含一個以上的元素</m:message>\r\n <m:type>System.InvalidOperationException</m:type>\r\n <m:stacktrace> 在 System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
\n 在 System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__2[TResult](IEnumerable`1 sequence)
\n 在 System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
\n 在 System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
\n 在 System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
\n 在 System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
\n 在 System.Data.Entity.Migrations.DbSetMigrationsExtensions.AddOrUpdate[TEntity](DbSet`1 set, IEnumerable`1 identifyingProperties, InternalSet`1 internalSet, TEntity[] entities)
\n 在 System.Data.Entity.Migrations.DbSetMigrationsExtensions.AddOrUpdate[TEntity](IDbSet`1 set, Expression`1 identifierExpression, TEntity[] entities)
\n 在 EbcBuy.Dal.Users.Data.Migrations.Configuration.Seed(EFDbContextUsers context)
\n 在 System.Data.Entity.Migrations.DbMigrationsConfiguration`1.OnSeed(DbContext context)
\n 在 System.Data.Entity.Migrations.DbMigrator.SeedDatabase()
\n 在 System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
\n 在 System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
\n 在 System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
\n 在 System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
\n 在 System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
\n 在 System.Data.Entity.MigrateDatabaseToLatestVersion`2.InitializeDatabase(TContext context)
\n 在 System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf`1.<CreateInitializationAction>b__e()
\n 在 System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
\n 在 System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
\n 在 System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c)
\n 在 System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
\n 在 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
\n 在 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
\n 在 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
\n 在 System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
\n 在 System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
\n 在 System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
\n 在 System.Linq.Queryable.Select[TSource,TResult](IQueryable`1 source, Expression`1 selector)
\n 在 EbcBuy.Bll.Users.Services.Impl.CustomersInfoService.GetQueryOfSingleRecord()
\n 在 EbcBuy.Bll.Users.Services.Impl.CustomersInfoService.GetCustomerById(Int64 ownerId, Int64 customerId)
\n 在 EbcBuy.Bll.Users.Services.Impl.CustomersInfoService.Add(CustomersInfo entity)
\n 在 EbcBuy.Bll.Users.WebApi.Controllers.CustomersInfoController.<>c__DisplayClass8.<Post>b__7() 位置 d:\\Set working folder\\EbcBuy.Bll\\EbcBuy.Bll.Users\\EbcBuy.Bll.Users.WebApi\\Controllers\\CustomersInfoController.cs:行號 75
\n 在 System.Threading.Tasks.Task`1.InnerInvoke()
\n 在 System.Threading.Tasks.Task.Execute()
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
\n 在 EbcBuy.Bll.Users.WebApi.Controllers.CustomersInfoController.<Post>d__a.MoveNext() 位置 d:\\Set working folder\\EbcBuy.Bll\\EbcBuy.Bll.Users\\EbcBuy.Bll.Users.WebApi\\Controllers\\CustomersInfoController.cs:行號 73
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()</m:stacktrace>\r\n </m:innererror>\r\n</m:error>"
============================================================
“System.InvalidOperationException”類型的未經處理的異常在 EntityFramework.dll 中發生
其他信息: 實體類型 ProductComments 不是當前上下文的模型的一部分。
【解決辦法】在Dal層相應的Data項目里,添加Map類(數據表與PO的映射),ProductCommentsMapping
========================================================
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<m:error xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n <m:code />\r\n <m:message xml:lang=\"en-US\">請求無效。</m:message>\r\n <m:innererror>\r\n <m:message>對於“EbcBuy.Bll.Orders.WebApi.Controllers.ComplaintController”中方法“System.Threading.Tasks.Task`1[System.Web.Http.IHttpActionResult] Patch(Int64, System.Web.Http.OData.Delta`1[EbcBuy.Bll.Orders.Models.Complaint])”的不可以為 null 的類型“System.Int64”的參數“key”,參數字典包含一個 null 項。可選參數必須為引用類型、可以為 null 的類型或聲明為可選參數。</m:message>\r\n <m:type></m:type>\r\n <m:stacktrace></m:stacktrace>\r\n </m:innererror>\r\n</m:error>"
【解決辦法】Patch方法key參數前加"[FromODataUri]
======================================================
【ComplaintLog實體類里有如下枚舉類型的屬性定義
public ComplainOperation OperationType { get; set; }
當有方法使用時,如OperationType = ComplainOperation.Apply,則在OData客戶端調用時會出現如下異常】
“System.InvalidOperationException”類型的未經處理的異常在 Microsoft.Data.Services.Client.dll 中發生
其他信息: 類型“EbcBuy.Bll.Common.Enums.ComplainOperation”沒有可設置的屬性。
【即使不使用該屬性,也會報上述異常。
但定義成可空類型的話,不使用不報異常,使用則報同樣異常。】
=======================================================
<m:message xml:lang="en-US">請求無效。</m:message>
−
<m:innererror>
−
<m:message>
對於“EbcBuy.Bll.Orders.WebApi.Controllers.ComplaintController”中方法“System.Web.Http.SingleResult`1[EbcBuy.Bll.Orders.Models.Complaint] Get(Int64)”的不可以為 null 的類型“System.Int64”的參數“key”,參數字典包含一個 null 項。可選參數必須為引用類型、可以為 null 的類型或聲明為可選參數。
</m:message>
【】通過ie測試ComplaintController的Get方法時,使用http://localhost:39380/odata/Complaint(281406301643290151) 這個url報錯。因為主鍵是long型, 所以,需在id后加L標記,即url改為http://localhost:39380/odata/Complaint(281406301643290151L)
=============================================================
<m:error>
<m:code/>
<m:message xml:lang="en-US">出現錯誤。</m:message>
−
<m:innererror>
−
<m:message>
“ObjectContent`1”類型未能序列化內容類型“application/json; charset=utf-8”的響應正文。
</m:message>
<m:type>System.InvalidOperationException</m:type>
<m:stacktrace/>
−
<m:internalexception>
−
<m:message>
'SingleResult`1' cannot be serialized using the ODataMediaTypeFormatter.
</m:message>
−
<m:type>
System.Runtime.Serialization.SerializationException
</m:type>
【解決辦法】在Get(key)方法上面加[Queryable]
=========================================
【執行userClient.GetEntities<ReturnOrder>().ToList();提示如下異常:】"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<m:error xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n <m:code />\r\n <m:message xml:lang=\"en-US\">出現錯誤。</m:message>\r\n <m:innererror>\r\n <m:message>“ObjectContent`1”類型未能序列化內容類型“application/atom+xml; charset=utf-8”的響應正文。</m:message>\r\n <m:type>System.InvalidOperationException</m:type>\r\n <m:stacktrace></m:stacktrace>\r\n <m:internalexception>\r\n <m:message>Null collections cannot be serialized.</m:message>\r\n <m:type>System.Runtime.Serialization.SerializationException</m:type>\r\n
<m:stacktrace> 在 System.Web.Http.OData.Formatter.Serialization.ODataCollectionSerializer.CreateODataValue(Object graph, IEdmTypeReference expectedType, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEdmTypeSerializer.CreateProperty(Object graph, IEdmTypeReference expectedType, String elementName, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateStructuralProperty(IEdmStructuralProperty structuralProperty, EntityInstanceContext entityInstanceContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateStructuralPropertyBag(IEnumerable`1 structuralProperties, EntityInstanceContext entityInstanceContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateEntry(SelectExpandNode selectExpandNode, EntityInstanceContext entityInstanceContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteEntry(Object graph, ODataWriter writer, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObjectInline(Object graph, IEdmTypeReference expectedType, ODataWriter writer, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteFeed(IEnumerable enumerable, IEdmTypeReference feedType, ODataWriter writer, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteObjectInline(Object graph, IEdmTypeReference expectedType, ODataWriter writer, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteObject(Object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content, HttpContentHeaders contentHeaders)
\n 在 System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()</m:stacktrace>\r\n </m:internalexception>\r\n </m:innererror>\r\n</m:error>"
【問題及解決辦法】在ReturnOrder的構造器里指定如下屬性初始化:
Pictures = new List<PictureModel>();
////ReturnOrderType = Common.Models.ReturnOrderType.RetailOrder;
//TheStatus = ReturnOrderStatus.AgreeReturnMoney;
//ServiceType = ReturnServiceType.None;
ReturnOrderLogs = new List<ReturnOrderLog>();
======================================================
【用[DataServiceEntity]聲明了PictureModel,
但未在WebApiConfig.cs中指定builder.EntitySet<PictureModel>("PictureModel");
會報如下異常:】
“System.InvalidOperationException”類型的未經處理的異常在 Microsoft.Data.Services.Client.dll 中發生
其他信息: 在 {http://schemas.microsoft.com/ado/2007/08/dataservices/metadata}:properties 元素中發現“EbcBuy.Bll.Orders.Models.ReturnOrder”類型上的“Pictures”屬性,並且它被聲明為導航屬性。ATOM 中的導航屬性必須表示為 {http://www.w3.org/2005/Atom}:link 元素。
============================================
【在WebApiConfig.cs中指定了builder.EntitySet<PictureModel>("PictureModel");,
但未用[DataServiceEntity]聲明了PictureModel。
會報如下異常:】
“System.InvalidOperationException”類型的未經處理的異常在 Microsoft.Data.Services.Client.dll 中發生
其他信息: 類型“EbcBuy.Bll.Orders.Models.ReturnOrder”上名為“Pictures”的屬性具有種類“Structural”,但它應為“Navigation”種類。
【解決辦法】用[DataServiceEntity]修飾PictureModel類
===============================================
【如果做了上述2處的設定, 則執行GetReturnOrderById調用ODataClient的GetEntity方法后,得到的Picture屬性值為null;
如果同時不做上述2處的設定,則執行GetReturnOrderById調用ODataClient的GetEntity方法后,得到的Picture屬性有值】
====================================================
【對於ReturnOrderLog實體,同時去掉上述2處設定,則會報如下異常:
(如果去掉Id屬性,則沒有異常發生,跟PictureModel一樣)】
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<m:error xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n <m:code />\r\n <m:message xml:lang=\"en-US\">出現錯誤。</m:message>\r\n <m:innererror>\r\n <m:message>“ObjectContent`1”類型未能序列化內容類型“application/atom+xml; charset=utf-8”的響應正文。</m:message>\r\n <m:type>System.InvalidOperationException</m:type>\r\n <m:stacktrace></m:stacktrace>\r\n <m:internalexception>\r\n <m:message>No NavigationLink factory was found for the navigation property 'ReturnOrderLogs' from entity type 'EbcBuy.Bll.Orders.Models.ReturnOrder' on entity set 'ReturnOrder'. Try calling HasNavigationPropertyLink on the EntitySetConfiguration.
\n參數名: navigationProperty</m:message>\r\n <m:type>System.ArgumentException</m:type>\r\n <m:stacktrace> 在 System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildNavigationLink(EntityInstanceContext instanceContext, IEdmNavigationProperty navigationProperty, ODataMetadataLevel metadataLevel)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateNavigationLink(IEdmNavigationProperty navigationProperty, EntityInstanceContext entityInstanceContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.<CreateNavigationLinks>d__1.MoveNext()
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteNavigationLinks(IEnumerable`1 navigationProperties, EntityInstanceContext entityInstanceContext, ODataWriter writer)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteEntry(Object graph, ODataWriter writer, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObjectInline(Object graph, IEdmTypeReference expectedType, ODataWriter writer, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObject(Object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content, HttpContentHeaders contentHeaders)
\n 在 System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()</m:stacktrace>\r\n </m:internalexception>\r\n </m:innererror>\r\n</m:error>"
============================================================
【】在WebApiConfig.cs中,如果加了builder.EntitySet<ContactInfoModel>("ContactInfoModel");則通過ie訪問的結果是:
{
"odata.metadata":"http://localhost:39380/odata/$metadata#ReturnOrder/@Element","ReturnOrderId":"1406271033590870","ReturnOrderType":0,"Product":{
"ProductId":"123","ProductName":"\u7fe0\u8d1d\u5361\u4e0a\u8863","MainPic":"this is a url here.","SkuId":123111,"SkuName":"\u9ad8\u8c03\u7ea2"
},"OrderId":"123","ServiceType":1,"FreightPayType":1,"AskQuantity":1,"ReturnMoney":"1120.00","ProblemDisc":"model.ProblemDisc","CustomerId":"111","CustomerName":"\u6d4b\u8bd5CustomerName","ShopId":"111","ShopName":"\u6d4b\u8bd5ShopName","TheStatus":1
}
【否則是】:
{
"odata.metadata":"http://localhost:39380/odata/$metadata#ReturnOrder/@Element","ReturnOrderId":"1406271033590870","ReturnOrderType":0,"Product":{
"ProductId":"123","ProductName":"\u7fe0\u8d1d\u5361\u4e0a\u8863","MainPic":"this is a url here.","SkuId":123111,"SkuName":"\u9ad8\u8c03\u7ea2"
},"OrderId":"123","ServiceType":1,"FreightPayType":1,"AskQuantity":1,"ReturnMoney":"1120.00","ProblemDisc":"model.ProblemDisc","CustomerId":"111","CustomerName":"\u6d4b\u8bd5CustomerName","CustomerContactInfo":{
"ProvinceId":0,"ProvinceName":"Hebei","CityId":0,"CityName":"Tangshan","CountyId":0,"CountyName":"Fengrun","Address":"\u5317\u4eac\u897f\u5b89\u9633\u4e1c18:0921:5303:44\u5f53\u65e5\u5230\u8fbe","ZipCode":"100100","LinkMan":"\u6bd4\u5c14\u76d6\u8328","Telephone":null,"MobilePhone":"18233334444","EMail":null
},"ShopId":"111","ShopName":"\u6d4b\u8bd5ShopName","ShopContactInfo":{
"ProvinceId":0,"ProvinceName":"Hebei","CityId":0,"CityName":"Tangshan","CountyId":0,"CountyName":"Fengrun","Address":"\u5317\u4eac\u897f\u5b89\u9633\u4e1c18:0921:5303:44\u5f53\u65e5\u5230\u8fbe","ZipCode":"100100","LinkMan":"\u6bd4\u5c14\u76d6\u8328","Telephone":null,"MobilePhone":"18233334444","EMail":null
},"TheStatus":1
}
=================================================
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<m:error xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n <m:code />\r\n <m:message xml:lang=\"en-US\">出現錯誤。</m:message>\r\n <m:innererror>\r\n <m:message>“ObjectContent`1”類型未能序列化內容類型“application/atom+xml; charset=utf-8”的響應正文。</m:message>\r\n <m:type>System.InvalidOperationException</m:type>\r\n <m:stacktrace></m:stacktrace>\r\n <m:internalexception>\r\n <m:message>No NavigationLink factory was found for the navigation property 'ReturnOrderLogs' from entity type 'EbcBuy.Bll.Orders.Models.ReturnOrder' on entity set 'ReturnOrder'. Try calling HasNavigationPropertyLink on the EntitySetConfiguration.
\n參數名: navigationProperty</m:message>
============================================
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<m:error xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n <m:code />\r\n <m:message xml:lang=\"en-US\">出現錯誤。</m:message>\r\n <m:innererror>\r\n <m:message>執行命令定義時出錯。有關詳細信息,請參閱內部異常。</m:message>\r\n <m:type>System.Data.Entity.Core.EntityCommandExecutionException</m:type>\r\n <m:stacktrace> 在 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
\n 在 System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
\n 在 System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__6()
\n 在 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
\n 在 System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
\n 在 System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
\n 在 System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
\n 在 System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
\n 在 System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
\n 在 System.Web.Http.QueryableAttribute.SingleOrDefault(IQueryable queryable, HttpActionDescriptor actionDescriptor)
\n 在 System.Web.Http.QueryableAttribute.ExecuteQuery(Object response, HttpRequestMessage request, HttpActionDescriptor actionDescriptor)
\n 在 System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
\n 在 System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__0.MoveNext()</m:stacktrace>\r\n <m:internalexception>\r\n <m:message>There is already an open DataReader associated with this Connection which must be closed first.</m:message>\r\n <m:type>MySql.Data.MySqlClient.MySqlException</m:type>\r\n <m:stacktrace> 在 MySql.Data.MySqlClient.ExceptionInterceptor.Throw(Exception exception)
\n 在 MySql.Data.MySqlClient.MySqlConnection.Throw(Exception ex)
\n 在 MySql.Data.MySqlClient.MySqlCommand.CheckState()
\n 在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
\n 在 MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
\n 在 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
\n 在 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)
\n 在 System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
\n 在 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
\n 在 System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
\n 在 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
\n 在 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)</m:stacktrace>\r\n </m:internalexception>\r\n </m:innererror>\r\n</m:error>"
============================================
<m:message>
The type 'EbcBuy.Bll.Orders.Models.ContactInfoModel' appears in two structurally incompatible initializations within a single LINQ to Entities query. A type can be initialized in two places in the same query, but only if the same properties are set in both places and those properties are set in the same order.
</m:message>
【問題&解決方法】我在GetReturnOrderById方法里同時給CustomerContactInfo和ShopContactInfo賦值,二者是ContactInfoModel類型。 如上提示,要求二者賦值的順序一樣,並且羅列相同的屬性。 改為如下
CustomerContactInfo = new ContactInfoModel
{
ProvinceName = a.CustomerArea.ProvinceName,
CityName = a.CustomerArea.CityName,
CountyName = a.CustomerArea.DistrictName,
Address = a.CustomerAddress,
LinkMan = a.CustomerLinkMan,
ZipCode = a.CustomerZipCode,
MobilePhone = a.CustomerPhone
},
...
ShopContactInfo = new ContactInfoModel
{
ProvinceName = a.ShopArea.ProvinceName,
CityName = a.ShopArea.CityName,
CountyName = a.ShopArea.DistrictName,
Address = a.ShopAddress,
LinkMan = a.ShopLinkMan,
ZipCode = a.ShopZipCode,
MobilePhone = a.ShopPhone,
//Telephone = a.ShopTel 【注釋掉】
},
===============================================
"<!DOCTYPE html>\r\n<html>\r\n <head>\r\n <title>分析器錯誤</title>\r\n <meta name=\"viewport\" content=\"width=device-width\" />\r\n <style>\r\n body {font-family:\"Verdana\";font-weight:normal;font-size: .7em;color:black;} \r\n p {font-family:\"Verdana\";font-weight:normal;color:black;margin-top: -5px}\r\n b {font-family:\"Verdana\";font-weight:bold;color:black;margin-top: -5px}\r\n H1 { font-family:\"Verdana\";font-weight:normal;font-size:18pt;color:red }\r\n H2 { font-family:\"Verdana\";font-weight:normal;font-size:14pt;color:maroon }\r\n pre {font-family:\"Consolas\",\"Lucida Console\",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}\r\n .marker {font-weight: bold; color: black;text-decoration: none;}\r\n .version {color: gray;}\r\n .error {margin-bottom: 10px;}\r\n .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }\r\n @media screen and (max-width: 639px) {\r\n pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }\r\n }\r\n @media screen and (max-width: 479px) {\r\n pre { width: 280px; }\r\n }\r\n </style>\r\n </head>\r\n\r\n <body bgcolor=\"white\">\r\n\r\n <span><H1>“/”應用程序中的服務器錯誤。<hr width=100% size=1 color=silver></H1>\r\n\r\n <h2> <i>分析器錯誤</i> </h2></span>\r\n\r\n <font face=\"Arial, Helvetica, Geneva, SunSans-Regular, sans-serif \">\r\n\r\n <b> 說明: </b>在分析向此請求提供服務所需資源時出錯。請檢查下列特定分析錯誤詳細信息並適當地修改源文件。\r\n <br><br>\r\n\r\n <b> 分析器錯誤消息: </b>未能加載類型“EbcBuy.Bll.Order.WebApi.WebApiApplication”。<br><br>\r\n\r\n <b>源錯誤:</b> <br><br>\r\n\r\n <table width=100% bgcolor=\"#ffffcc\">\r\n <tr>\r\n <td>\r\n <code><pre>\r\n\r\n<font color=red>行 1: <%@ Application Codebehind="Global.asax.cs" Inherits="EbcBuy.Bll.Order.WebApi.WebApiApplication" Language="C#" %>\r\n</font></pre></code>\r\n\r\n </td>\r\n </tr>\r\n </table>\r\n\r\n <br>\r\n\r\n <b> 源文件: </b> /global.asax<b> 行: </b> 1\r\n <br><br>\r\n\r\n <hr width=100% size=1 color=silver>\r\n\r\n <b>版本信息:</b> Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.18446\r\n\r\n </font>\r\n\r\n </body>\r\n</html>\r\n<!-- \r\n[HttpException]: 未能加載類型“EbcBuy.Bll.Order.WebApi.WebApiApplication”。\r\n 在 System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError)\r\n 在 System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly)\r\n 在 System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData)\r\n[HttpParseException]: 未能加載類型“EbcBuy.Bll.Order.WebApi.WebApiApplication”。\r\n 在 System.Web.UI.TemplateParser.ProcessException(Exception ex)\r\n 在 System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)\r\n 在 System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)\r\n[HttpParseException]: 未能加載類型“EbcBuy.Bll.Order.WebApi.WebApiApplication”。\r\n 在 System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)\r\n 在 System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)\r\n 在 System.Web.UI.TemplateParser.ParseInternal()\r\n 在 System.Web.UI.TemplateParser.Parse()\r\n 在 System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()\r\n 在 System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)\r\n 在 System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()\r\n 在 System.Web.Compilation.BuildProvidersCompiler.PerformBuild()\r\n 在 System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp)\r\n 在 System.Web.Compilation.BuildManager.CompileGlobalAsax()\r\n 在 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()\r\n[HttpException]: 未能加載類型“EbcBuy.Bll.Order.WebApi.WebApiApplication”。\r\n 在 System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()\r\n 在 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()\r\n 在 System.Web.Compilation.BuildManager.CallAppInitializeMethod()\r\n 在 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)\r\n[HttpException]: 未能加載類型“EbcBuy.Bll.Order.WebApi.WebApiApplication”。\r\n 在 System.Web.HttpRuntime.FirstRequestInit(HttpContext context)\r\n 在 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)\r\n 在 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)\r\n-->"
=============================================
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<m:error xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n <m:code />\r\n <m:message xml:lang=\"en-US\">出現錯誤。</m:message>\r\n <m:innererror>\r\n <m:message>“ObjectContent`1”類型未能序列化內容類型“application/atom+xml; charset=utf-8”的響應正文。</m:message>\r\n <m:type>System.InvalidOperationException</m:type>\r\n <m:stacktrace></m:stacktrace>\r\n <m:internalexception>\r\n <m:message>No NavigationLink factory was found for the navigation property 'ReturnOrderLogs' from entity type 'EbcBuy.Bll.Orders.Models.ReturnOrder' on entity set 'ReturnOrder'. Try calling HasNavigationPropertyLink on the EntitySetConfiguration.
\n參數名: navigationProperty</m:message>\r\n <m:type>System.ArgumentException</m:type>\r\n <m:stacktrace> 在 System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildNavigationLink(EntityInstanceContext instanceContext, IEdmNavigationProperty navigationProperty, ODataMetadataLevel metadataLevel)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.CreateNavigationLink(IEdmNavigationProperty navigationProperty, EntityInstanceContext entityInstanceContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.<CreateNavigationLinks>d__1.MoveNext()
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteNavigationLinks(IEnumerable`1 navigationProperties, EntityInstanceContext entityInstanceContext, ODataWriter writer)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteEntry(Object graph, ODataWriter writer, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObjectInline(Object graph, IEdmTypeReference expectedType, ODataWriter writer, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteFeed(IEnumerable enumerable, IEdmTypeReference feedType, ODataWriter writer, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteObjectInline(Object graph, IEdmTypeReference expectedType, ODataWriter writer, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteObject(Object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
\n 在 System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content, HttpContentHeaders contentHeaders)
\n 在 System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)
\n--- 引發異常的上一位置中堆棧跟蹤的末尾 ---
\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n 在 System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()</m:stacktrace>\r\n </m:internalexception>\r\n </m:innererror>\r\n</m:error>"
===========================================================
類型“EbcBuy.Bll.Common.Models.ReturnServiceType”沒有可設置的屬性。
在 System.Data.Services.Client.ClientEdmModel.GetOrCreateEdmType(Type type)
在 System.Data.Services.Client.Materialization.StructuralValueMaterializationPolicy.ApplyDataValue(ClientTypeAnnotation type, ODataProperty property, Object instance)
在 System.Data.Services.Client.Materialization.EntryValueMaterializationPolicy.MaterializeResolvedEntry(MaterializerEntry entry, Boolean includeLinks)
在 System.Data.Services.Client.Materialization.EntryValueMaterializationPolicy.Materialize(MaterializerEntry entry, Type expectedEntryType, Boolean includeLinks)
在 System.Data.Services.Client.Materialization.ODataEntityMaterializer.DirectMaterializePlan(ODataEntityMaterializer materializer, MaterializerEntry entry, Type expectedEntryType)
在 System.Data.Services.Client.Materialization.ODataEntityMaterializerInvoker.DirectMaterializePlan(Object materializer, Object entry, Type expectedEntryType)
在 System.Data.Services.Client.ProjectionPlan.Run(ODataEntityMaterializer materializer, ODataEntry entry, Type expectedType)
在 System.Data.Services.Client.Materialization.ODataEntityMaterializer.ReadImplementation()
在 System.Data.Services.Client.Materialization.ODataMaterializer.Read()
在 System.Data.Services.Client.MaterializeAtom.MoveNextInternal()
在 System.Data.Services.Client.MaterializeAtom.MoveNext()
在 System.Linq.Enumerable.<CastIterator>d__b1`1.MoveNext()
在 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
在 EbcBuy.Bll.Users.Test.OrderODataClientTest.Test() 位置 d:\Project_v3\EbcBuy.Bll\EbcBuy.Bll.Users\EbcBuy.Bll.Users.Test\OrderODataClientTest.cs:行號 17
在 EbcBuy.Bll.Users.Test.Program.Main(String[] args) 位置 d:\Project_v3\EbcBuy.Bll\EbcBuy.Bll.Users\EbcBuy.Bll.Users.Test\Program.cs:行號 21
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
=========================================================
The entity type ReturnOrder is not part of the model for the current context.
在 System.Data.Entity.Internal.InternalContext.UpdateEntitySetMappingsForType(Type entityType)
在 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
在 System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
在 System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
在 System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
在 System.Linq.Queryable.Select[TSource,TResult](IQueryable`1 source, Expression`1 selector)
在 EbcBuy.Bll.Orders.Services.Impl.ReturnOrderService.GetReturnOrderList() 位置 d:\Project_v3\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.Services\Impl\ReturnOrderService.cs:行號 41
在 EbcBuy.Bll.Orders.WebApi.Controllers.ReturnOrderController.Get() 位置 d:\Project_v3\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Order.WebApi\Controllers\ReturnOrderController.cs:行號 43
在 lambda_method(Closure , Object , Object[] )
在 System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
在 System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
在 System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
=================================================================
{"客戶端和服務之間的類型不匹配。類型“EbcBuy.Bll.Orders.Models.ReturnOrder”不是實體類型,但是響應負載中的類型表示實體類型。請確保在客戶端上定義的類型與服務的數據模型匹配,或更新客戶端上的服務引用。"}
在 System.Data.Services.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)
在 System.Data.Services.Client.DataServiceQuery`1.Execute()
在 System.Data.Services.Client.DataServiceQuery`1.GetEnumerator()
在 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
在 EbcBuy.Bll.Orders.UnitTest.ODataClient.Test() 位置 d:\Project_v3\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.UnitTest\ODataClient.cs:行號 17
在 EbcBuy.Bll.Orders.UnitTest.Program.Main(String[] args) 位置 d:\Project_v3\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.UnitTest\Program.cs:行號 18
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
=======================================================
{"未能加載文件或程序集“Microsoft.Data.Edm, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)":"Microsoft.Data.Edm, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}
在 System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
在 System.Reflection.RuntimeModule.GetTypes()
在 System.Reflection.Assembly.GetTypes()
在 System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
在 System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition)
在 System.ComponentModel.Composition.Hosting.DirectoryCatalog.<>c__DisplayClass3.<GetExports>b__2(ComposablePartCatalog catalog)
在 System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
在 System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
在 System.ComponentModel.Composition.Hosting.CatalogExportProvider.InnerCatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
在 System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
在 System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
在 System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
在 System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
在 System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
在 System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
在 System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
在 System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
在 System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
在 System.ComponentModel.Composition.Hosting.ExportProvider.GetExportsCore(Type type, Type metadataViewType, String contractName, ImportCardinality cardinality)
在 System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValuesCore[T](String contractName)
在 System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValues[T](String contractName)
在 EbcBuy.Dal.Orders.Data.Initialize.EFDbContextOrders.get_EntityMappers() 位置 d:\Project_v3\EbcBuy.Dal\EbcBuy.Dal.Orders\EbcBuy.Dal.Orders.Data\Initialize\EFDbContextOrders.cs:行號 36
在 Quick.Framework.Data.EFDbContext.OnModelCreating(DbModelBuilder modelBuilder) 位置 d:\Project_v3\Quick.Framework\Quick.Framework.Data\EFDbContext.cs:行號 26
在 System.Data.Entity.DbContext.CallOnModelCreating(DbModelBuilder modelBuilder)
在 System.Data.Entity.Internal.LazyInternalContext.CreateModelBuilder()
在 System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
在 System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
==========================================================
"{\"Message\":\"未找到與請求 URI“http://localhost:39380/api/ReturnOrder()/$count”匹配的 HTTP 資源。\",\"MessageDetail\":\"未找到與名為“ReturnOrder()”的控制器匹配的類型。\"}"
====================================================
"<!DOCTYPE html>\r\n<html>\r\n <head>\r\n <title>未能加載文件或程序集“Microsoft.Data.Services.Client”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)</title>\r\n <meta name=\"viewport\" content=\"width=device-width\" />\r\n <style>\r\n body {font-family:\"Verdana\";font-weight:normal;font-size: .7em;color:black;} \r\n p {font-family:\"Verdana\";font-weight:normal;color:black;margin-top: -5px}\r\n b {font-family:\"Verdana\";font-weight:bold;color:black;margin-top: -5px}\r\n H1 { font-family:\"Verdana\";font-weight:normal;font-size:18pt;color:red }\r\n H2 { font-family:\"Verdana\";font-weight:normal;font-size:14pt;color:maroon }\r\n pre {font-family:\"Consolas\",\"Lucida Console\",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}\r\n .marker {font-weight: bold; color: black;text-decoration: none;}\r\n .version {color: gray;}\r\n .error {margin-bottom: 10px;}\r\n .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }\r\n @media screen and (max-width: 639px) {\r\n pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }\r\n }\r\n @media screen and (max-width: 479px) {\r\n pre { width: 280px; }\r\n }\r\n </style>\r\n </head>\r\n\r\n <body bgcolor=\"white\">\r\n\r\n <span><H1>“/”應用程序中的服務器錯誤。<hr width=100% size=1 color=silver></H1>\r\n\r\n <h2> <i>未能加載文件或程序集“Microsoft.Data.Services.Client”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)</i> </h2></span>\r\n\r\n <font face=\"Arial, Helvetica, Geneva, SunSans-Regular, sans-serif \">\r\n\r\n <b> 說明: </b>執行當前 Web 請求期間,出現未經處理的異常。請檢查堆棧跟蹤信息,以了解有關該錯誤以及代碼中導致錯誤的出處的詳細信息。\r\n\r\n <br><br>\r\n\r\n <b> 異常詳細信息: </b>System.IO.FileLoadException: 未能加載文件或程序集“Microsoft.Data.Services.Client”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)<br><br>\r\n\r\n <b>源錯誤:</b> <br><br>\r\n\r\n <table width=100% bgcolor=\"#ffffcc\">\r\n <tr>\r\n <td>\r\n <code>\r\n\r\n執行當前 Web 請求期間生成了未經處理的異常。可以使用下面的異常堆棧跟蹤信息確定有關異常原因和發生位置的信息。</code>\r\n\r\n </td>\r\n </tr>\r\n </table>\r\n\r\n <br>\r\n\r\n <b>程序集加載跟蹤:</b> 下列信息有助於確定程序集“Microsoft.Data.Services.Client”未能加載的原因。<br><br>\r\n\r\n <table width=100% bgcolor=\"#ffffcc\">\r\n <tr>\r\n <td>\r\n <code><pre>\r\n\r\n警告: 程序集綁定日志記錄被關閉。\r\n要啟用程序集綁定失敗日志記錄,請將注冊表值 [HKLM\\Software\\Microsoft\\Fusion!EnableLog] (DWORD)設置為 1。\r\n注意: 會有一些與程序集綁定失敗日志記錄關聯的性能損失。\r\n要關閉此功能,請移除注冊表值 [HKLM\\Software\\Microsoft\\Fusion!EnableLog]。\r\n</pre></code>\r\n\r\n </td>\r\n </tr>\r\n </table>\r\n\r\n <br>\r\n\r\n <b>堆棧跟蹤:</b> <br><br>\r\n\r\n <table width=100% bgcolor=\"#ffffcc\">\r\n <tr>\r\n <td>\r\n <code><pre>\r\n\r\n[FileLoadException: 未能加載文件或程序集“Microsoft.Data.Services.Client”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)]\r\n\r\n[FileLoadException: 未能加載文件或程序集“Microsoft.Data.Services.Client, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)]\r\n System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0\r\n System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34\r\n System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152\r\n System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77\r\n System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16\r\n System.Reflection.Assembly.Load(String assemblyString) +28\r\n System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38\r\n\r\n[ConfigurationErrorsException: 未能加載文件或程序集“Microsoft.Data.Services.Client, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)]\r\n System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752\r\n System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218\r\n System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130\r\n System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170\r\n System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91\r\n System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +285\r\n System.Web.Compilation.BuildManager.ExecutePreAppStart() +153\r\n System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516\r\n\r\n[HttpException (0x80004005): 未能加載文件或程序集“Microsoft.Data.Services.Client, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)]\r\n System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9915300\r\n System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101\r\n System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254\r\n</pre></code>\r\n\r\n </td>\r\n </tr>\r\n </table>\r\n\r\n <br>\r\n\r\n <hr width=100% size=1 color=silver>\r\n\r\n <b>版本信息:</b> Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.18446\r\n\r\n </font>\r\n\r\n </body>\r\n</html>\r\n<!-- \r\n[FileLoadException]: 未能加載文件或程序集“Microsoft.Data.Services.Client”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)\r\n[FileLoadException]: 未能加載文件或程序集“Microsoft.Data.Services.Client, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)\r\n 在 System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)\r\n 在 System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)\r\n 在 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)\r\n 在 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)\r\n 在 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)\r\n 在 System.Reflection.Assembly.Load(String assemblyString)\r\n 在 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)\r\n[ConfigurationErrorsException]: 未能加載文件或程序集“Microsoft.Data.Services.Client, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)\r\n 在 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)\r\n 在 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()\r\n 在 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)\r\n 在 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)\r\n 在 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()\r\n 在 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)\r\n 在 System.Web.Compilation.BuildManager.ExecutePreAppStart()\r\n 在 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)\r\n[HttpException]: 未能加載文件或程序集“Microsoft.Data.Services.Client, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一個依賴項。找到的程序集清單定義與程序集引用不匹配。 (異常來自 HRESULT:0x80131040)\r\n 在 System.Web.HttpRuntime.FirstRequestInit(HttpContext context)\r\n 在 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)\r\n 在 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)\r\n-->"
=================================================
{
"odata.metadata":"http://localhost:39380/odata/$metadata#ProductInfo","value":[
{
"ProductId":"1","ProductName":"1","MarketPrice":"1.00","PurchasePrice":"1.00","HasNormalInvoice":true,"HasSpecialInvoice":true,"SupplierName":"1","Weight":1.0,"ServiceInfo":"1","OtherInfo":"1","Policy":"1","Length":0.0,"Width":0.0,"Height":0.0,"IsDeleted":false,"CreatedUserId":null,"CreatedTime":null,"ModifiedTime":null
}
]
}
===========================================================
{"無法加載在應用程序配置文件中指定的 DbConfiguration 類型“MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6”。請確保使用限定程序集的名稱且該程序集對運行的應用程序可用。有關詳細信息,請參閱 http://go.microsoft.com/fwlink/?LinkId=260883。"}
在 System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
在 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
在 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
在 System.Activator.CreateInstance[T]()
在 Quick.Framework.Data.UnitOfWork`1..ctor() 位置 d:\Project_EbcBuy\Quick.Framework\Quick.Framework.Data\UnitOfWork.cs:行號 18
在 EbcBuy.Dal.Orders.Data.Initialize.UnitContextOrders..ctor()
在 EbcBuy.Bll.Orders.Services.Impl.ComplaintService..ctor() 位置 d:\Project_EbcBuy\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.Services\Impl\ComplaintService.cs:行號 25
在 EbcBuy.Bll.Orders.UnitTest.ComplaintServiceUT..ctor() 位置 d:\Project_EbcBuy\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.UnitTest\ComplaintServiceUT.cs:行號 28
在 EbcBuy.Bll.Orders.UnitTest.Program.Main(String[] args) 位置 d:\Project_EbcBuy\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.UnitTest\Program.cs:行號 25
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
=====================
{"There is already an open DataReader associated with this Connection which must be closed first."}
在 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
在 System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
在 System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__6()
在 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
在 System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
在 System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
在 System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
在 System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
在 System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
在 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
在 lambda_method(Closure , OrderInfo )
在 System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
在 System.Linq.Buffer`1..ctor(IEnumerable`1 source)
在 System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
在 System.Linq.Enumerable.<SkipIterator>d__4d`1.MoveNext()
在 System.Linq.Enumerable.<TakeIterator>d__3a`1.MoveNext()
在 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
在 EbcBuy.Bll.Orders.Services.Impl.OrderInfoService.GetOrderList(OrderQueryModel condition, Int32 pageIndex, Int32 pageSize) 位置 d:\Project_EbcBuy\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.Services\Impl\OrderInfoService.cs:行號 109
在 EbcBuy.Bll.Orders.UnitTest.OrderInfoServiceUT.TestGetList() 位置 d:\Project_EbcBuy\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.UnitTest\OrderInfoServiceUT.cs:行號 78
在 EbcBuy.Bll.Orders.UnitTest.Program.Main(String[] args) 位置 d:\Project_EbcBuy\EbcBuy.Bll\EbcBuy.Bll.Orders\EbcBuy.Bll.Orders.UnitTest\Program.cs:行號 25
在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
========================================================================
【訪問http://localhost:39385/api/CustomersInfo提示:】
<m:message>
支持“EFDbContextUsers”上下文的模型已在數據庫創建后發生更改。請考慮使用 Code First 遷移更新數據庫(http://go.microsoft.com/fwlink/?LinkId=238269)。
</m:message>
<m:type>System.InvalidOperationException</m:type>
【我刪掉數據庫后,再刷新,發現又是下面的錯誤:】
<m:message>實體類型 CustomersInfo 不是當前上下文的模型的一部分。</m:message>
<m:type>System.InvalidOperationException</m:type>
在 System.Data.Entity.Internal.InternalContext.UpdateEntitySetMappingsForType(Type entityType)
在 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
在 System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
在 System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
在 System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
在 System.Linq.Queryable.Select[TSource,TResult](IQueryable`1 source, Expression`1 selector)
在 EbcBuy.Bll.Users.Services.Impl.CustomersInfoService.GetCustomerList() 位置 d:\Set working folder\EbcBuy.Bll\EbcBuy.Bll.Users\EbcBuy.Bll.Users.Services\Impl\CustomersInfoService.cs:行號 29
在 EbcBuy.Bll.Users.WebApi.Controllers.CustomersInfoController.Get() 位置 d:\Set working folder\EbcBuy.Bll\EbcBuy.Bll.Users\EbcBuy.Bll.Users.WebApi\Controllers\CustomersInfoController.cs:行號 34
在 lambda_method(Closure , Object , Object[] )
在 System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
在 System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
在 System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
【原因:】 跟EFDbContextUsers.cs里獲取DirectoryCatalog的path有關。 宿主是控制台應用程序的,在..../bin/debug下, 宿主是Web的,在..../bin下。 如下代碼:var catalog = new DirectoryCatalog((AppDomain.CurrentDomain.SetupInformation.PrivateBinPath)); 只適合宿主是web的。
如下代碼可以兼顧以上2種情況:
var dir = AppDomain.CurrentDomain.BaseDirectory;
if (!dir.Contains("bin"))
{
dir += "\\bin";
}
