locked
Compilation error when publishing an asp.net web site RRS feed

  • Question

  • User-1030985626 posted

    Hey all,

    This is the first time i publish a web site on a server so i would appreciate if your answers will be as simple as possible.

    I am using Visual studio 2010.

    The server is IIS 7.

    I copied all the files to the server with the built in ftp client of Visual Studio. (App_Code, App_Data, JS directory and other aspx and aspx.cs files)

    I dont know if its relevent or not but i added some dll files to my project (im using fluent NHibernate)

    When i navigate to a page wich uses objects that i defined (in the App_Code) i get this compilation error.

    CS0400: The type or namespace name 'ContentType' could not be found in the global namespace (are you missing an assembly reference?)

    "ContentType" is a enum that i defined.

    in my local machine everything is ok and runs perfectly.

    Why is this happening?

    Thursday, September 1, 2011 4:28 PM

All replies

  • User-691759321 posted

    To properly publish a website to a server you should use the built in Publish feature, which compiles the server side code (.vb or .cs files) and copies only the aspx, ascx, etc files to the server.  The other option is the Copy Web Site function which copies all files including the necessary dlls and compiled classes.  These are the best two ways to publish a site to a server.  The first mention will only work if the server has Front Page 2002 extensions installed.  My guess is you are missing the proper file structure to locate the dlls for your classes and other objects.  Try one of the two methods I listed and it should fix the problem.

    Thursday, September 1, 2011 4:35 PM
  • User-1030985626 posted

    I used the copy web site function that you mentioned. All of my source code and dll files where copied to the server.

    Maybe they are not compiled? thats the only explenation i can think of.

    My file and folder structure is exactly like on my local machine. 

    i uploaded all of my files and folder (in the same structure) to [MY_SERVER_IP]/httpdocs/demo.

    maybe im copying them to the worng place?

    Friday, September 2, 2011 1:20 AM
  • User-691759321 posted

    Does your website run locally?  All your class files need to be in the App_Code directory, including Enums.  Be sure to build the project locally before copying or it might not copy the latest dll.  Make sure you are running the right ASP.NET version on the server.  Make sure the directory has the proper access rights. 

    Tuesday, October 11, 2011 3:23 PM