HomeSeer / Plugin-SDK

Plugin development kit for the 4th major edition of the HomeSeer platform.
https://www.nuget.org/packages/HomeSeer-PluginSDK/
GNU Affero General Public License v3.0
20 stars 4 forks source link

AccessLevel = 2; NullReferenceException #74

Closed stefxx closed 4 years ago

stefxx commented 4 years ago

Environment and System Config

Describe the bug When setting AccessLevel to 2, my plugin crashes at startup. This: _plugin.Connect(args) results in this error:

System.NullReferenceException: 'Object reference not set to an instance of an object.
This exception was originally thrown at this call stack:
System.Runtime.Remoting.Messaging.LogicalCallContext.PropagateIncomingHeadersToCallContext(System.Runtime.Remoting.Messaging.IMessage)
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(ref System.Runtime.Remoting.Proxies.MessageData, int)
    HomeSeer.PluginSdk.AbstractPlugin.Connect(int)
    HomeSeer.PluginSdk.AbstractPlugin.Connect(string[])
    HSPI_Neato.Program.Main(String()) in HSPI.vb

Setting AccessLevel to 1 is working as expected. Here is the code I am using to set AccessLevel:

Public Overrides ReadOnly Property AccessLevel As Integer
    Get
        Return 2
    End Get
End Property
stefxx commented 4 years ago

Ok,I figured it out. This only happens when the Plugin Name and Id in the code are different from the updater Name and Id. After publishing a plugin, the Name/Id from the updater will be used in a HSPI_*.exe.json file, and if they do not match with the Name/Id in your plugin, things start to break.

Not only this, but also plugin status, start, stop etc breaks if the Name/Id do not match.