2012-03-14 6 views
3

Visual Studio 11 Developer Previewでアプリケーションを作成していますが、reader.InputStreamOptions = InputStreamOptions.Partialを使用してアプリケーションをしばらく実行するとこのエラーが発生します。オプションセット:Windows 8 Consumer Preview + Visual Studio 11 DeveloperプレビューのソケットBUG

An unhandled exception of type 'System.Exception' occurred in mscorlib.dll 

Additional information: The operation attempted to access data outside the valid range (Exception from HRESULT: 0x8000000B) 

このオプションが設定されていない場合、ソケットはストリームを正常に読み取ることができます。ここ

は参考のためのコードである:

private StreamSocket tcpClient; 
    public string Server = "10.1.10.64"; 
    public int Port = 6000; 
    VideoController vCtrl = new VideoController(); 
    /// <summary> 
    /// Initializes the singleton application object. This is the first line of authored code 
    /// executed, and as such is the logical equivalent of main() or WinMain(). 
    /// </summary> 
    public App() 
    { 
     tcpClient = new StreamSocket(); 
     Connect(); 
     this.InitializeComponent(); 
     this.Suspending += OnSuspending; 
    } 

    public async void Connect() 
    { 
     await tcpClient.ConnectAsync(
        new Windows.Networking.HostName(Server), 
        Port.ToString(), 
        SocketProtectionLevel.PlainSocket); 

     DataReader reader = new DataReader(tcpClient.InputStream); 
     Byte[] byteArray = new Byte[1000]; 
     //reader.InputStreamOptions = InputStreamOptions.Partial; 
     while (true) 
     { 


      await reader.LoadAsync(1000); 
      reader.ReadBytes(byteArray); 

      // unsafe 
      //{ 
      // fixed(Byte *fixedByteBuffer = &byteArray[0]) 
      // { 
      vCtrl.Consume(byteArray); 
      vCtrl.Decode(); 
      // } 
      //} 
     } 


    } 
+0

例外がreader.ReadBytesで発生します。 – pkumar0

+3

質問は何ですか? – driis

+0

これはバグですか?そこに修正が来ますか?ほとんどの人がVisual Studio 11 Betaを使用しているので、最後のプルはそれ以外の場合は破損します。 – pkumar0

答えて

1

InputStreamOptions.Partialはバイト未満の要求数が利用可能な場合LoadAsyncが完了することができることを意味します。したがって、完全に要求されたバッファサイズを必ずしも読み取ることはできません。

はこれを試してみてください:

public async void Connect() 
{ 
    await tcpClient.ConnectAsync(
     new Windows.Networking.HostName(Server), 
     Port.ToString(), 
     SocketProtectionLevel.PlainSocket); 

    DataReader reader = new DataReader(tcpClient.InputStream); 
    reader.InputStreamOptions = InputStreamOptions.Partial; 
    while (true) 
    { 
    var bytesAvailable = await reader.LoadAsync(1000); 
    var byteArray = new byte[bytesAvailable]; 
    reader.ReadBytes(byteArray); 

    // unsafe 
    //{ 
    // fixed(Byte *fixedByteBuffer = &byteArray[0]) 
    // { 
    vCtrl.Consume(byteArray); 
    vCtrl.Decode(); 
    // } 
    //} 
    } 
} 

ところで、マイクロソフトのバグを報告するために適切な場所がMicrosoft Connectです。

関連する問題