3
我在Visual Studio 11開發人員預覽版中編寫了一個應用程序,在應用程序運行了一段時間後,我收到了此錯誤信息reader.InputStreamOptions = InputStreamOptions.Partial;選項集:Windows 8 Consumer Preview中的套接字BUG + Visual Studio 11開發人員預覽
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();
// }
//}
}
}
閱讀器中發生異常.ReadBytes調用 – pkumar0 2012-03-14 20:41:56
這是什麼問題? – driis 2012-03-14 20:43:02
這是一個錯誤?有沒有解決方法?最後一個pull會被損壞,否則 – pkumar0 2012-03-14 23:11:52