Storeasync() is giving exception in windows 8 but working fine in windows phone 8

2
StreamSocket socket = null;
DataWriter datawriter = null;
DataReader dataReader = null;
socket = new StreamSocket();
datawriter = new DataWriter(socket.OutputStream);
dataReader = new DataReader(socket.InputStream);  

public async Task<byte[]> sendreceive(byte[] bytes)
{
    try
    {
        datawriter.WriteBytes(bytes);
        await datawriter.StoreAsync(); //Exception here
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

//connect the socket
socket = new StreamSocket();
await socket.ConnectAsync(
    rfcommService.ConnectionHostName, 
    rfcommService.ConnectionServiceName,
    SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);

The exception comes is: A first chance exception of type 'System.InvalidOperationException' occurred in filename.exe

Additional information: A method was called at an unexpected time. (Exception from HRESULT: 0x8000000E)

Please help if anyone can.

c#
windows
exception
bluetooth
asked on Stack Overflow Mar 16, 2015 by user925 • edited Mar 18, 2015 by RJFalconer

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0