簡體   English   中英

為什么我的應用在 AppHarbor 上運行時表現不同?

[英]Why is my app behaving differently when running on AppHarbor?

我正在開發一個 wcf RESTful web 服務,它使用實體框架和代碼優先來管理由 AppHarbor 中的 SQL Server 附加組件托管的數據庫。 現在,如果我通過使用啟動 IIS 來托管應用程序的 Visual Studio 調試在本地運行我的應用程序,則一切正常。 但是,如果我測試在 AppHarbor 中部署的服務(沒有錯誤),一切都會出錯,我會收到 400 Bad Request。 這是 http 響應中的堆棧跟蹤:

at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at    System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__6()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery`1.Execute(MergeOption mergeOption)
at System.Data.Entity.Core.Objects.DataClasses.EntityReference`1.Load(MergeOption mergeOption)
at System.Data.Entity.Core.Objects.DataClasses.RelatedEnd.DeferredLoad()
at System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.LoadProperty[TItem](TItem propertyValue, String relationshipName, String targetRoleName, Boolean mustBeNull, Object wrapperObject)
at System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.<>c__DisplayClass7`2.<GetInterceptorDelegate>b__2(TProxy proxy, TItem item)
at System.Data.Entity.DynamicProxies.UserCloudConn_100557DBEEC4B39F64FD7786B8E2F4080B576D2C357C3C1161822268F4233178.get_cloud()
at CloudStorageManager.MainService.GetActiveServices(UserCredential data) in d:\temp\inywl51q.z0c\input\DropboxWebService\Services\MainService.svc.cs:line 870
at CloudStorageManager.MainService.GetAvailableServices(UserCredential data) in d:\temp\inywl51q.z0c\input\DropboxWebService\Services\MainService.svc.cs:line 943
at SyncInvokeGetAvailableServices(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

例如,這是我的一段代碼,它給出了 appharbor 問題:

var cloudsConn = (from c in context.UserCloudConn where user.id == c.userId select c);

foreach (UserCloudConn conn in cloudsConn)
{
    list.Add(conn.cloud.name); // HERE THE STACK TRACE GIVE ME AN ERROR. LINE 870
}

這是我使用的模型:

public class DatabaseEntities : DbContext
{
    public DatabaseEntities() : base("name=DatabaseConnectionString") { }

    public DbSet<User> Users { get; set; }
    public DbSet<Cloud> Clouds { get; set; }
    public DbSet<UserCloudConn> UserCloudConn { get; set; }
}

public class User
{
    [Key]
    [Column(Order = 1)]
    public int id { get; set; }
    [Key]
    [Column(Order = 2)]
    public string email { get; set; }
    public string password { get; set; }
    public string accessToken { get; set; }
    public string name { get; set; }
    public string surname { get; set; }
    public virtual ICollection<UserCloudConn> userCloudConn { get; set; } // ogni user ha n tuple in UserCloudConn

}

public class Cloud
{
    [Key]
    public int id { get; set; }
    public string name { get; set; }
    public string appKey { get; set; }
    public string appSecret { get; set; }
    public virtual ICollection<UserCloudConn> userCloudConn { get; set; } // ogni cloud ha n tuple in UserCloudConn
}

public class UserCloudConn
{
    [Key]
    [Column(Order = 1)] 
    public int userId { get; set; }
    [Key]
    [Column(Order = 2)] 
    public int cloudId { get; set; }
    public string accessToken { get; set; }
    public string accessSecret { get; set; }
    public string email { get; set; }
    public string password { get; set; }
    public string refreshToken { get; set; }
    public int expireIn { get; set; }
    public string tokenType { get; set; }
    public string timeStamp { get; set; }
    public virtual Cloud cloud { get; set; } // Ogni tupla in UserCloudConn è associata ad un cloud
    public virtual User user { get; set; } // Ogni tupla in UserCloudConn è associata ad uno User

}

編輯:我做了一些測試,我發現問題是當我使用虛擬的 UserCloudConn 類的雲屬性時。 我想我應該用 linq 做另一個查詢以從我的數據庫中獲取雲,但是為什么這在 appharbor 上不起作用,但它在本地機器上運行???

我有這個錯誤,因為在本地連接字符串中我將 MultipleActiveResulSet 添加為 true,但在 AppHarbor SQL 服務器設置中,我沒有激活它。 所以是我的錯。 現在它起作用了。 謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM