I tried the the example code in section 31.2 Object Allocation (free eBook version 1.02), with my FEZ Domino.
using System.Threading;
using System;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT;
namespace MFConsoleApplication1
{
public class Program
{
static SPI _spi = new SPI(new SPI.Configuration(
Cpu.Pin.GPIO_NONE, false, 0, 0, false,
true, 1000, SPI.SPI_module.SPI1));
static byte[] buffer = new byte[2];
static void WriteRegister(byte register_num, byte value)
{
buffer[0] = register_num;
buffer[1] = value;
_spi.Write(buffer);
_spi.Dispose();
}
public static void Main()
{
...
I got an Unhandled exception error message:
#### Exception System.ObjectDisposedException - 0x00000000 (1) ####
#### ...
After some trials & errors, I commented out the line says:
_spi.Dispose();
in the " WriteRegister method like this:
The program works!
static void WriteRegister(byte register_num, byte value)
{
buffer[0] = register_num;
buffer[1] = value;
_spi.Write(buffer);
// _spi.Dispose();
}
Is this because NETMF automatically dispose the buffer? Anyone?
Like Jeff said, the easier you make it for other to understand your code and problem the more answers you will get back. I personally hate reading code that is not code tagged. Very much pain to read
When you dispose an object that means you no longer need to use it. So, why are you disposing the objects?
Sorry guys,
I did try to use the quote tool, code tool in my message.
But It did not work for me, since the new tool bar above the reply message.
I could not use the quote, code, hyperlink, bold, italic, etc…
I remember it used to work for me then, before the web page was changed to the new design.
I could not even put the smiley face into my message box anymore.
<— it happened like this!!!
Is this something to do with the viewer?
I’m using Internet Explorer 8 on the XP Pro system.
Oh, yeah. The formatting tools are not working in IE8 right now (forgot that until I was just trying to post some code). Hopefully Josh will get that fixed soon :