Maple Server null reference exception

I tracked down where in the code, regarding the Maple Web Server, where I am seeing a NULL reference exception.

I have done little to no web development and tried a few ways to get past this but ultimately cause other issues…
The issue is in the src code in: MapleServer.cs Method: Context at line 152.

target = ((Type)handler).GetConstructor(new Type[] { }).Invoke(new object[] { }); <-- NULL reference

I have attempted to break this line into multiple lines to pinpoint exactly why its failing but as far as I can tell it is in GetConstructor().

Does anyone have an idea??

Hi @Brad_Patterson - it sounds like maybe you’re having the same issue as me (see System.NullReferenceException on Maple GET Requests)? I have a lot of web development experience in C# so will try to take a look at the source - thanks for sharing this! Please share any breakthroughs that you might have as well - thanks! :slight_smile:

Hey Isho

Yes I believe that we are seeing the same thing. I did not have a lot of time this weekend to look at this but when I did I tried to understand the object that was being cast to Type. I think it is a HttpWebRequest but I cannot tell 100%. I thought that if I could figure out the actual type I could add a check to implicitly create the object first and then attempt the failing line of code. So far no luck…

I just saw another post where some one used nuget to install the Netduino Foundation - is it possible that some dependency is missing and fails? I will try adding Netduino Foundation and see if that works tonight.

I’m at work now and cannot install VS2015 since we are on VS2017.

Regards
Brad

1 Like

I tried adding Foundation via nuget and still get the error; I’m new to current-gen Netduino development - is there another way to add it (I don’t see it in references for example)? Are you sure it’s a dependency itself? (I was not using it prior, and adding it didn’t seem to change anything) Thanks!!! :heart:

@Brad_Patterson had a bit of a breakthrough with this tonight - I was somewhat flailing at it at this point so I’m not 100% certain of precisely what fixed it, but you can see everything I did in this diff here:

I believe it was a combination of adding:

Install-Package Netduino.Foundation.Network

in addition to the base Foundation itself plus this line here:

which was based on the RgbLedHost example, and which contradicts both the documentation and advice I found in another thread here. I’m now able to successfully GET without any errors and everything is working as expected Maple-wise. I wanted to share this in hopes that it might help others - I can’t begin to describe the time spent and frustration endured to get to this point, only for it to be some trivial tweaks that just weren’t in the docs/were incorrect in the docs. Hopefully this helps someone else though … :weary: :+1:

1 Like

Interesting, you shouldn’t “need” Netduino.Foundation.Network to use Maple but I would recommend it simply because it makes it really easy to know when you have a valid network connection.

I’ll investigate and see if I can reproduce the issue.

2 Likes

Thanks Adrian - when I say “need” I guess what I meant was “in order to get networking and Maple working based on the examples/docs” - which included a network check, like you say. Honestly I think the main thing was using the RgbLedHost example’s code vs. Maple’s own that fixed the titular issue. :heart:

Ishotjr

First thing thank you - Saturday evening I was finally able to apply your changes to get the Maple server working with issue. Sunday I ran out of time to completely get something running for my project but hope to get something through the week.

Thank you again for your help.
Brad

1 Like