I have recently run nuget auto package restore on my entire Visual Studio 2015 solution. Of course, this was a very bad idea and I spent few days fixing missing dlls and manually troubleshooting package issues cross my 7 projects in the solution.
I, however, still face these issues:
The type or namespace name 'Notifications' does not exist in the namespace 'Microsoft.ServiceBus' (are you missing an assembly reference?)
and
The name 'NotificationHubClient' does not exist in the current context
That occur in this code:
using System;
using System.Collections.Generic;
using System.Configuration;
using Microsoft.ServiceBus.Notifications;
namespace B8AK.Service
{
/// <summary>
/// Summary description for PushNotification
/// </summary>
public class PushNotification
{
/// <summary>
/// Send push notification
/// </summary>
/// <param name="msg">Message</param>
/// <param name="key">SPID or Customer mobile</param>
/// <returns></returns>
public static bool Send(string msg, string key)
{
try
{
var notificationHubClint = NotificationHubClient.CreateClientFromConnectionString(ConfigurationManager.AppSettings["ServiceBusPushNotificationConnectionString"], ConfigurationManager.AppSettings["ServiceBusPushNotificationName"]);
Dictionary<string, string> param = new Dictionary<string, string>();
param.Add("message", msg);
param.Add("alert", msg);
var template = new TemplateNotification(param);
List<string> tagList = new List<string>();
tagList.Add(key);
notificationHubClint.SendNotificationAsync(template, tagList);
return true;
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
return false;
}
}
}
}
Despite having the 'Microsoft.ServiceBus.dll' referenced in my project.
After Stackoverflowing this issue, I came cross a solution that suggest to change the target framework from .Net client profile to the Full profile from the project properties, but in my case, I am already running the full .net profile.