Я пишу приложение в Visual Studio 11 Developer Preview, и я получаю эту ошибку после того, как приложение какое-то время запускается, с reader.InputStreamOptions = InputStreamOptions.Partial;набор параметров:
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();
// }
//}
}
}