'Unity Error CS0246 NuGet Package MQTT not found, despite installed with no Visual Studio Errors
I am having an issue with both Unity 2017.2.4f1 and Visual Studio 2017(2) 15.9.44. The situation is I need to install a MQTT plugin and I did so via NuGet and while Visual Studio is showing me no errors, warnings while building successfully, Unity is erroring. The error, is it seems to think the namespaces of: ‘uPLibrary’, ‘MqttClient’ and ‘MqttMsgPublishEventArgs’ is could not be found with error CS0246. I tried the following links for troubleshooting: https://support.unity.com/hc/en-us/articles/206116726-What-is-CS0246- and Metadata file '.dll' could not be found (the latter links was from a .NET framework issue where I had to set Unity from ‘Stable 3.5 Equivalent’ to ‘Experimental 4.6 Equivalent’.
I am not sure what to do anymore. My goal is simply to get a MQTT plugin so my Unity VR project will receive data. May I please have some help? I am not sure what else to do.
Thank you for your time.
Post Script, I tired to include images but I needed at least ten reputation points.
Code (text):
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using uPLibrary.Networking.M2Mqtt;
using uPLibrary.Networking.M2Mqtt.Messages;
public class MQTTClient : MonoBehaviour
{
// Create instance.
MqttClient mqttClient = new MqttClient("localhost");
public void start()
{
// Register message to recieve.
mqttClient.MqttMsgPublishReceived += client_recievedMessage;
string clientID = Guid.NewGuid().ToString();
mqttClient.Connect(clientID);
Debug.Log("Subscriber: MachineData/");
mqttClient.Subscribe(new string[] { "MachineData/" }, new byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE });
}
static void client_recievedMessage(object sender, MqttMsgPublishEventArgs e)
{
//Handle message recieved.
var message = System.Text.Encoding.Default.GetString(e.Message);
Debug.Log(":Message recieved: " + message);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|