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.

bvince05

Member Since 26 Mar 2015
Offline Last Active Jun 10 2015 07:20 AM
-----

Topics I've Started

Device.Start method (.NET MF 4.3)

01 April 2015 - 08:20 AM

Anybody have any experience using the new Device.Start method?

 

It requires an instance of a ServerBindingContext.  I'm completely lost as to what this is and how I'm supposed to instantiate it given it requires a ProtocolVersion AND a BindingProperty.  I look at the BindingProperty documenation and it really doesn't explain what it is :(.

 

 

 

Any help would be greatly appreciated :).

 

Thanks,

Brian 


WCF Service Host issues (.net MF 4.3)

31 March 2015 - 05:06 PM

Hello everyone,

 

I'm absolutely loving my Netduino Plus 2!  But I am having some serious trouble trying to get a WCF service hosted on my hardware.  As I read the .Net Micro Framework 4.3 SDK docs, it appears that most of the difficult stuff like worrying about WSDL files/discovery/etc are taken care of under the hood (which is great and how it's done in full .net).  That said, I cannot seem to get my service up and running...or find any examples of people doing the same thing in this specific version of .Net MF.  

 

My service is here:

[ServiceContract]
    public interface IBriansWCFService
    {
        [OperationContract]
        void LED1(bool value);

        [OperationContract]
        void SendSerialMsg(string message);

    }


    public class MyService : DpwsHostedService, IBriansWCFService
    {

        private MySerialPort sPort;
        private MyBoard mBoard;

        public MyService(ProtocolVersion pVersion)
            : base(pVersion)
        {
            sPort = new MySerialPort();
            mBoard = new MyBoard();

            
        }



        public void LED1(bool value)
        {
            throw new NotImplementedException();
        }

        public void SendSerialMsg(string message)
        {
            throw new NotImplementedException();
        }
    }

As you can see, I developed a simple DpwsHostedService.  This part, for me, was straight forward as it is almost identical to how you develop services in full .NET.  

 

 

It's the next part that is confusing (a little bit ambiguous in the docs) and where I believe I'm having my problems.


 public class Program
    {
        public static void Main()
        {
 
            //instantiate protocol version to use everywhere it needs one (alot of places apparently)
            ProtocolVersion11 protocolVer = new ProtocolVersion11();
 
            //instantiate my service and provide protocol version as DpwsHostService requires it
            MyService mService = new MyService(protocolVer);
            
            Debug.Print(Device.IPV4Address);
 
            //this line throws a null pointer exception!
            //Device.HostedServices.Add(mService);
 
 
            //initialize my Device stack with protocol version and HTTP binding
            Device.Initialize(new WS2007HttpBinding(), protocolVer);
            
            //start my Device's stack
            Device.Start(new Ws.Services.Binding.ServerBindingContext(protocolVer, new Ws.Services.Binding.BindingProperty[0] ));
 
            Debug.Print(Device.IPV4Address);
            
 
        }
 
    }

First, whenever I add my instantiated service to the Device.HostedServices stack, it throws a null pointer exception...so I commented this out.  Once commented, if I try and execute the Device.start method, it throws another (but different) type of exception.

 

I was hoping that this community might be able to shed some light on what I'm missing and doing wrong.  This rally isn't far off from how you do this in full .NET and so I fell I'm missing something small but crucial.

 

Can you awesome people help me?

 

Thanks!


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.