WindowsIotCore Raspberry Pi UWP Serial port access issue(System.AccessViolationException)

0

I am trying to use the serial pin of the Raspberry Pi 3 for input for a UWP app on the WindowsIotCore platform. I keep getting this exception:

System.AccessViolationException
HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an 
indication that other memory is corrupt.

The code where this exception occurs is:

SerialDevice serialPort = null;
string aqs = SerialDevice.GetDeviceSelector();
var dis = await DeviceInformation.FindAllAsync(aqs);
serialPort = await SerialDevice.FromIdAsync(dis[0].Id);
serialPort.WriteTimeout = TimeSpan.FromMilliseconds(500);
serialPort.ReadTimeout = TimeSpan.FromMilliseconds(200);
serialPort.BaudRate = 9600;
serialPort.Parity = SerialParity.None;
serialPort.StopBits = SerialStopBitCount.One;
serialPort.DataBits = 8;
serialPort.Handshake = SerialHandshake.None;

Update: I created a new UWP project and used the same code, on the same platform, on the same Raspberry Pi, using the same development PC, the code worked fine then.

c#
uwp
raspberry-pi
windows-10-iot-core
asked on Stack Overflow Aug 31, 2018 by daniyal selani • edited Sep 1, 2018 by daniyal selani

1 Answer

0

I managed to solve this issue by editing the package.appxmanifest file using notepad++ I had already edited the package.appxmanifest file through visual studio 2017, however i checked again and for some reason, any edits made to the file through visual studio 2017 were not being saved. After using an external editor to edit the file, i found no issue with my code. The issue is solved now.

answered on Stack Overflow Sep 5, 2018 by daniyal selani

User contributions licensed under CC BY-SA 3.0