Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

adam8797

Member Since 17 Jul 2013
Offline Last Active Jun 25 2017 03:35 PM
-----

#51653 Make instance of module static

Posted by adam8797 on 24 July 2013 - 01:05 AM

I was having issues with this code:

using System;using GoBus;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using NetduinoGo;using System.Threading;using SecretLabs.NETMF.Hardware.NetduinoGo;namespace MFConsoleApplication1{    public class Program    {        //notice the static ShieldBase        static ShieldBase shieldBase = new ShieldBase(GoSockets.Socket5);        public static void Main()        {            var ledPort = new OutputPort(shieldBase.Pins.GPIO_PIN_D4, false);            while (true)            {                ledPort.Write(!ledPort.Read());                System.Threading.Thread.Sleep(250);            }        }    }}

It throws this:

An unhandled exception of type 'System.Exception' occurred in GoBusSerialTransport.dll

but this code works fine:

using System;using GoBus;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using NetduinoGo;using System.Threading;using SecretLabs.NETMF.Hardware.NetduinoGo;namespace MFConsoleApplication1{    public class Program    {        public static void Main()        {            ShieldBase shieldBase = new ShieldBase(GoSockets.Socket5);            var ledPort = new Microsoft.SPOT.Hardware.OutputPort(shieldBase.Pins.GPIO_PIN_D4, false);            while (true)            {                ledPort.Write(!ledPort.Read());                System.Threading.Thread.Sleep(250);            }        }    }}

Why can't I have a static instance of a go!bus module? 

 

A similar exception happened when I tried to use the button (making it static vs not static) except the exception occurred in a different dll (whichever one contains the button)




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.