0

I have a web forms project which I've just ported to VS2015.

On the Master Page, I have the following public method which sets a response message:

public void SetResponse(string responseMessage, Utilities.ResponseType cssClass)
{
    ResponseToUser.Text = !String.IsNullOrWhiteSpace(responseMessage) ? Utilities.GetResponse(responseMessage, cssClass) : "";
}

In the Utilities.cs file, I have the enum and the GetResponse:

namespace WEB
{
    public class Utilities
    {
        public enum ResponseType
        {
            Success,
            Info,
            Warning,
            Danger
        }

        public static string GetResponse(string message, ResponseType response)
        {
            return "<div id=\"response\" class=\"alert alert-" + response.ToString().ToLower() +
               " fade in\"><a href=\"#\" class=\"close\" data-dismiss=\"alert\">&times;</a>" + message + "</div>";
        }
    }
}

In the child pages, I make calls to the public method on the master page, like so:

if (Request.QueryString["msg"] == "changepassword")
    Master.SetResponse("Please change your password before continuing", Utilities.ResponseType.Warning);

VS2015 is showing the Master.SetResponse as an error, saying:

CS0012 The type 'Utilities.ResponseType' is defined in an assembly that is not referenced. You must add a reference to assembly 'App_Code.pay9mvri, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

error as shown

At the top of the child page, I have the reference to the Utilities namespace:

using WEB;

So the ResponseType enum IS in a referenced namespace. Why is it highlighting it as an error? The website still builds and runs fine, but I'd like to get rid of all the error messages. This wasn't an issue in VS2013 - the exact same project.

Sean
  • 14,359
  • 13
  • 74
  • 124
  • Could you please add assembly names, namespaces and class names to your code examples? – Stefan Over May 13 '15 at 07:18
  • *You must add a reference to assembly 'App_Code.pay9mvri* - have you tried clearing your .NET Framework cache & restarted the machine? Seems like it has an old version stuck in the temporary files – CodingIntrigue May 13 '15 at 07:19
  • @RGraham that's what I suspected, I tried a rebuild but no luck, and it's happening across projects/solutions too. Restarting the PC also doesn't help. Any more ideas? – Sean May 13 '15 at 11:04
  • Hmm, I had a look here - some of these answers may apply - http://stackoverflow.com/questions/496269/asp-net-page-says-i-need-to-reference-an-assembly-that-does-not-exist – CodingIntrigue May 13 '15 at 11:05
  • @Herdo I'm not sure which names you need, I thought I'd included all the relevant ones. – Sean May 13 '15 at 11:05
  • @RGraham there's nothing in my temp .net folders at all. Tried the compilation batch thing too. The code isn't in an assembly so I can't add references - it's in the App_Code folder... – Sean May 13 '15 at 11:28
  • Seems to be a bug in VS2015. If I create a website from scratch, with an enum in a class file, and try call a public method on the Master Page from the webform passing an enum value, I get the same error. – Sean May 13 '15 at 11:51

1 Answers1

0

I reinstalled the latest version of VS and that seems to have fixed the problem.

Sean
  • 14,359
  • 13
  • 74
  • 124