1

簡単に言えば、

Visual Studio 2012 RC Silverlight 5 アプリケーションはゲーム を消費するASP.net 4でホストされるWCF 4 サービス共有ポータブル ライブラリを介した ChannelFactory 手法を使用するアプリケーション .NET4/SL5にはAsync CTPを使用するiGameインターフェイスが含まれる

グラフ :
ASP.NET <=クラス ライブラリ (ゲーム) <=ポータブル ライブラリ (iGame) => Silverlight

ポータブル ライブラリ

[ServiceContract]
public interface iGame
{
    [OperationContract]
    Task<bool> Request ( string Key );
}

クラス ライブラリ

[ServiceBehavior ( InstanceContextMode = InstanceContextMode . Single , ConcurrencyMode = ConcurrencyMode . Multiple , UseSynchronizationContext = true )]
public class Game : iGame
{
    public async Task<bool> Request ( string Key )
    {
        return await Task . Factory . StartNew ( ( ) => true );
    }
}

シルバーライト

    private async void myButton_Click ( object sender , RoutedEventArgs e )
    {
        if ( await Messenger . Instance . Client . Request ( XXX . Text ) ) // Exception
            NavigationService . Navigate ( new Uri ( "/Views/YYY.xaml" , UriKind . Relative ) );
    }
  • Messenger は、ChannelFactory を介してクライアント プロキシを開始および保存するシングルトン クラスです。

System.InvalidOperationException: The contract 'iGame' contains synchronous operations, which are not supported in Silverlight. Split the operations into "Begin" and "End" parts and set the AsyncPattern property on the OperationContractAttribute to 'true'. Note that you do not have to make the same change on the server.
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__0(Object state)

が問題なのですか? O_o

4

1 に答える 1