VS generates warnings when building on remote server but no warnings when building on local pc

Last post 05-15-2008 5:49 PM by samw. 7 replies.

Sort Posts:

  • VS generates warnings when building on remote server but no warnings when building on local pc

    04-30-2008, 5:05 PM
    • Loading...
    • samw
    • Joined on 06-08-2005, 1:00 PM
    • Posts 53

    I have a website I am working on that I code/test on my local PC then copy to a production server. 

    Today I opened the web site on the production server and was surprised to see that visual studio catches several errors in my code that it does not catch when I build the project on the web server running on my local PC.  For example, VS caught this error on the production server:

      if(Session["FileID"] != "0")
                file = SuiteFiles.GetFile(int.Parse(Session["FileID"].ToString()));

    On the prod server I get a warning that says : Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'.  This warning is very helpful - as you can see I am missing .ToString() on the Session reference.  When I open this same file and build the web site on my local pc, I get no warning.   How do I fix that? 

    I looked around VS a bit and found a setting under Tools->Options->Debugging->General.  The options are:  "Enable property evaluation and other implicit function calls", and "Call toString() on objects in variables windows (C# only).  Both these are checked and toggling them appeared to make no difference (which is expected - I am using the same copy of VS to open prod/local).  The web config files on local/production are approximately the same.  PC is running XP, IIS 5, prod server is running IIS 5 also.
     

     

    Thanks 

  • Re: VS generates warnings when building on remote server but no warnings when building on local pc

    05-01-2008, 10:44 PM

    Hi,

    In your case, please make sure that you select show warning option on your local Visual Studio (Enter website's Property Pages, then select Accessibility, and then check Warnings checkbox under Show group).

    I suggest you validate if this Session is null before using it, because it is the object type. For example:

            if (Session["FileID"] != null)
            {
                if (Session["FileID"].ToString() != "0")
                { 

                }
            }

     

    I hope this helps.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: VS generates warnings when building on remote server but no warnings when building on local pc

    05-02-2008, 4:44 PM
    • Loading...
    • samw
    • Joined on 06-08-2005, 1:00 PM
    • Posts 53

    Hi Thomas,  thanks for your help.  I checked the warnings setting and it is already checked.

    Any other suggestions?   

  • Re: VS generates warnings when building on remote server but no warnings when building on local pc

    05-04-2008, 12:56 AM
    Answer

    Hi,

    Thanks for your response.

    Did your local VS only show the error message instead of warning message on the Error List window? In your case, you can try to set the Warning level to control what warning message will be shown while building.

    You can set the Warning Level on the Page directive, for example:

    <%@ Page Language="C#" AutoEventWireup="true" CompilerOptions="/warn:4"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

    If your project is ASP.NET web application project, you can set it on the Properties page (Enter Properties page-> Build tab -> Set Warning Level under Errors and Warnings group).

     

    I hope this helps. 

     

     

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: VS generates warnings when building on remote server but no warnings when building on local pc

    05-07-2008, 4:41 PM
    • Loading...
    • samw
    • Joined on 06-08-2005, 1:00 PM
    • Posts 53

    Hello, 

     

    The build tab has no Errors and Warnings Group.  Am I using the right properties? i.e. right click on project name ->  Property Pages

    Also, the default warn level is 4 and I am not changing that so I think I should be getting the same messages if I compile on the server or the pc.

     

    Thanks for your help.
     

     

  • Re: VS generates warnings when building on remote server but no warnings when building on local pc

    05-07-2008, 9:57 PM

    Hi,

    The Errors and Warnings Group I mentioned is available in website project. But your project is ASP.NET Web application.

     

    I hope this helps.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: VS generates warnings when building on remote server but no warnings when building on local pc

    05-08-2008, 5:36 PM
    • Loading...
    • samw
    • Joined on 06-08-2005, 1:00 PM
    • Posts 53

    I'm pretty sure it is a web project. 

  • Re: VS generates warnings when building on remote server but no warnings when building on local pc

    05-15-2008, 5:49 PM
    • Loading...
    • samw
    • Joined on 06-08-2005, 1:00 PM
    • Posts 53

    I still have not found a resolution to this.  It hasn't been a top priority but I would still like to know why VS is working the way it is.

     

    Thanks,

     

    Sam 

Page 1 of 1 (8 items)