簡體   English   中英

Xaml Designer崩潰

[英]Xaml Designer crashes

我在我的項目中使用VS 2012,而且我對XAML設計人員也很滿意。

Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteException

No connection string named '************' could be found in the application config file.
   at System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator()
   at *************.ViewModel.**********.<GetReferralList>b__1d() in d:\******.cs:line 422
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at ***************.<GetReferralList>d__29.MoveNext() in *******************\MainTabViewModel.cs:line 391
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__1(Object state)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

這是造成問題的代碼

await Task.Run(() =>
        {
            using (var context = new SCMEntities())
            {
                var listOfGenRefReg = context.GenericReferralRegistrationIs;
                foreach (var item in listOfGenRefReg)
                {
                         Application.Current.Dispatcher.Invoke(() =>
                            LastReferrals.Add(item));

                }

            }

理想的是為設計人員提供一個ViewModel ,為運行時提供一個ViewModel 這取決於將MainTabViewModelView 在您的View使用以下代碼段確定它在設計器中的執行時間:

bool isInDesignMode = DesignerProperties.GetIsInDesignMode(this)

this是您的View

您應該使用結果跳過任何與數據庫相關的執行。

您正在嘗試訪問在設計器中不起作用的數據庫。 您需要重構代碼,以便可以在必要時使用設計時數據,並且僅在運行時使用數據庫。

暫無
暫無

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

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