locked
Type or namespace name .... could not be found after changing Build Action RRS feed

  • Question

  • User1731768004 posted

    I have looked through a number of answer to this error and I am a little confused.

    Scenario. I am developing a website with VS2010. I am developing using local code and server based data. When we are happy with the system we deploy to the server using the Build->Publish menu which deploys to a the server using a share.

    Last night after making changes I clicked deploy and the website did not work I was getting errors saying it could not find the classes, so after a bit of searching I found a reference that told me to change the class files to have Build Action property Content and Copy to Output set to "copy if newer"

    This sorted out the website and people coudl use. Now on the local development machine I am getting the Type or namespace error, and no matter what option I choose, or how many times a clean a rebuild this will not go away, and none of the classes are being found.

    I have classes in the App_Code folder and created another folder classes and still it does not see any of the classes.

    I suppose I would like sorting this out, but I actually really want to understand how the whoel thing works, why are some folders found under the application name if for example i type appname and then press control space then press the "." I am not getting either "App_code" or "classes" coming up.

    Is there some option in the build properties that I have messed up - this is very fustrating why does the one environment need a different settig to the other.

    Thursday, June 20, 2013 8:55 AM

Answers

  • User1731768004 posted

    This makes no sense, so I created a new folder appcodes and the created a new cs file of the same name of on of the class that was giving this error.

    I then copied an pasted the code in the file, and renamed the original, and all of a sudden the project could recognise the class as long as I added using appname.appcodes.

    I then looked at the properties of that file and saw that Build Action was set to Compile and Copy To Output was set to Do not copy

    I then when back to the other class files and set the Copy To Output property to Do not copy on all the file and it fixed everything.

    Why is this? This setting makes 0 sense. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 21, 2013 2:20 PM

All replies

  • User1751268424 posted

    Hi,

    Please post your classes and code using the classes.

    Have fun

    Thursday, June 20, 2013 9:22 AM
  • User1731768004 posted

    There are well over 20 of them some data mainly classes some with code. The site is working fine in the live environment I just cannot run it locally. These build options seem to affect the file and the folder, and I am not sure how to change the folder settings.

    I will list a few below:

    namespace TrackerDotNet.classes
    {
      public class OrderHeaderData
      {
        //  CustomerId, OrderDate, RoastDate, RequiredByDate, ToBeDeliveredBy, Confirmed, Done, Notes
    
        public OrderHeaderData()
        {
          _otCustomerID = _otToBeDeliveredBy = 0;
          _otNotes = "";
          _otOrderDate = _otRoastDate = _otRequiredByDate  = DateTime.Now;
          _otConfirmed = true;
          _otDone = false;
        }
    
        private long _otCustomerID;
        private long _otToBeDeliveredBy;
        private DateTime _otOrderDate;
        private DateTime _otRoastDate;
        private DateTime _otRequiredByDate;
        private bool _otConfirmed;
        private bool _otDone;
        private string _otNotes;
    
        public long CustomerID      { get { return _otCustomerID; } set { _otCustomerID = value; } }
        public long ToBeDeliveredBy { get { return _otToBeDeliveredBy; } set { _otToBeDeliveredBy = value; } }
        public DateTime OrderDate   { get { return _otOrderDate; } set { _otOrderDate = value; } }
        public DateTime RoastDate   { get { return _otRoastDate; } set { _otRoastDate = value; } }
        public DateTime RequiredByDate { get { return _otRequiredByDate; } set { _otRequiredByDate = value; } }
        public bool Confirmed       { get { return _otConfirmed; } set { _otConfirmed = value; } }
        public bool Done            { get { return _otDone; } set { _otDone = value; } }
        public string Notes         { get { return _otNotes; } set { _otNotes = value; } }
    
      }
    }
    
    namespace TrackerDotNet.classes
    {
    
      public class OrderCls
      {
        private OrderHeaderData _Header;
        private List<OrderDetailData> _Items;
    
        public OrderCls()
        {
          _Header = new OrderHeaderData();
          List<OrderDetailData> _Items = new List<OrderDetailData>();
        }
    
        public OrderHeaderData HeaderData      
        { 
          get {return _Header; } 
          set {_Header = value; } 
        }
        public List<OrderDetailData> ItemsData 
        {
          get {return _Items; } 
          set {_Items = value; } 
        }
      }
    




    Thursday, June 20, 2013 9:56 AM
  • User1751268424 posted

    Hi,

    I can not find any problem on the class you have sent.

    You may check the

    I have classes in the App_Code folder and created another folder classes and still it does not see any of the classes.

    Try to set "View All" at the Solution explorer, and then you may find class under App_Code, not on "C#" logo at the class. Right click these classes if any and select "Include in a project".

    Since this is a class, there is should be no relation with "copy if newer"

    Have fun

    Thursday, June 20, 2013 11:55 AM
  • User1731768004 posted

    This makes no sense, so I created a new folder appcodes and the created a new cs file of the same name of on of the class that was giving this error.

    I then copied an pasted the code in the file, and renamed the original, and all of a sudden the project could recognise the class as long as I added using appname.appcodes.

    I then looked at the properties of that file and saw that Build Action was set to Compile and Copy To Output was set to Do not copy

    I then when back to the other class files and set the Copy To Output property to Do not copy on all the file and it fixed everything.

    Why is this? This setting makes 0 sense. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 21, 2013 2:20 PM