2011-04-18 1 views
0

젠틀맨입니다. 나는 MainPage.xaml을, 실버 라이트 프로젝트에서 정의를 다음과 같습니다 (모든 사전 초기화 속성에 대해 잘 작동 바인딩 디자인 타임 데이터에 사용되는 Engine.Login.Model 프로젝트에VS2010 디자인 타임 데이터를로드 할 때 WCF를 사용할 때의 시간 오류

<UserControl 
xmlns:model="clr-namespace:Engine.Silverlight.Web.Views;assembly=Engine.Login.Model" 
d:DataContext="{d:DesignInstance Type=model:DesignTimeModel, IsDesignTimeCreatable=True}">... 

그리고 클래스, 하지만) :

public class DesignTimeModel : INotifyPropertyChanged 
{ 
    public DesignTimeModel() 
    { 
     var d = Deployment.Current.Dispatcher; 
     d.BeginInvoke(
      () => 
      { 
       CacheClient c = new CacheClient(); 
       c.GetResourcesCompleted +=(s,e)=> 
        { 
         d.BeginInvoke(
          () => this.Resources = e.Result); 
        }; 
       c.GetResourcesAsync(); 
      } 
     ); 

불행히도, 난 (내가 인스턴스 과정 VS 1에 부착하여 VS의 다른 인스턴스를 사용하여 디버깅하려하지만 도움이되지 않습니다 완료 WCF 요청 후 System.ObjectDisposedException을 가지고 - 같은 오류를, 아니 추가 정보) :

System.ObjectDisposedException 
Cannot access a disposed object. 
Object name: 'Dispatcher'. 
    at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result) 
    at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) 

Dispatcher 동작이 디자인 모드와 다른 것으로 가정합니다. VS2010 XAML 디자이너에서 WCF를 사용하여 디자인 타임 데이터를 가져 오는 문제를 해결하는 방법을 알려주십시오.

답변

0

먼저 디자인 타임 클래스에서 WCF 호출을 만드는 것이 최선의 방법은 아니라는 것을 믿습니다! 대신에 일부 정적 더미 데이터를 넣어야합니다.

문제가있는 경우 변수를 지정하는 대신 Deployment.Current.Dispatcher을 직접 사용해보십시오.

+0

[링크] (http://stackoverflow.com/questions/3236095/how-to-have-a-blendable-project-using-mvvm-light-and-wcf-ria-services) – Override

+0

[링크] (http://stackoverflow.com/questions/3236095/how-to-have-a-blendable-project-using-mvvm-light-and-wcf-ria-services) [link] (http://openlightgroup.net) /Blog/tabid/58/EntryId/87/Silverlight-MVVM-Enabling-Design-Time-Data-in-Expression-Blend-When-Using-Web-Services.aspx) WCF 디자인 타임을 가진 예제 목록을 보았습니다. , 나는 왜 당신이 좋지 않다고 생각하는지 모르겠다. Btw, 내가 권장 한 코드 변경 사항 - 도움이되지 않습니다 ... – Override

관련 문제