Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

.cs Files not found (C#.NET)

  • 26-04-2011 1:14pm
    #1
    Registered Users, Registered Users 2 Posts: 3,992 ✭✭✭


    Im currently working on an application in .NET and had added a number of classes (months ago). They were working perfectly fine and I set about doing other tasks.

    Now all of a sudden It seems like they are broken, even though nothing has changed.

    When I try navigating to one of the pages I get the following error:
    Server Error in '/Tester' Application.
    --------------------------------------------------------------------------------
    
    Parser Error 
    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 
    
    Parser Error Message: The file '/~/Asp/CCJTester/JTester_add.aspx.cs' does not exist.
    
    Source Error: 
    
    Line 1:  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="JTester_add.aspx.cs" Inherits="JTest_code1_add" MasterPageFile="~/Site.master" %>
    Line 2:  
    Line 3:  
    

    So it seems like the .cs files aren't being packed into the DLL file..

    Ive spent most of today on this and cannot get it sorted.. ANyone got any suggestions as to what I can try?


Comments

  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Ensure that the CS is set to Compile and not content in the Properties section. That's all I got for ya so if it's already set to compile then I'd just recreated the page and class file.


  • Registered Users, Registered Users 2 Posts: 3,992 ✭✭✭Korvanica


    John_Mc wrote: »
    Ensure that the CS is set to Compile and not content in the Properties section. That's all I got for ya so if it's already set to compile then I'd just recreated the page and class file.

    Tried both of them with No luck...

    Forgot to add: when I Debug the Application, everything works perfectly. All these pages load with no problems. When I publish to our server, these errors start to occur.

    Anyway Ive tried the following after some googling and discussing with colleagues...

    • Change user Permissions,
    • Change Visual Studio Permissinos,
    • Delete all dll files and rebuild/republish
    • Toggle custom error mode (on/off)
    • Deleted the files themselves and recreated them from scratch.
    • Made sure the .cs file was set to compile.
    • Created a new local application and virtual directory and published to my machine. Same errors.

    nothing helped... GAH!!!!!!!!!!!!!!!


  • Registered Users, Registered Users 2 Posts: 15,065 ✭✭✭✭Malice


    Funnily enough I think I know exactly what the problem is :).
    In your .aspx page where you have
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="JTester_add.aspx.cs" Inherits="JTest_code1_add" MasterPageFile="~/Site.master" %>
    I think you should have
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JTester_add.aspx.cs" Inherits="JTest_code1_add" MasterPageFile="~/Site.master" %>

    Basically the CodeBehind attribute will cause the code in the .cs file to be compiled into an assembly whereas the CodeFile attribute will defer that until runtime which means the .cs file will be needed on the server. When you do a Publish it doesn't copy the .cs files as it thinks you don't need them. The application works locally because the .cs file exists locally.


  • Registered Users, Registered Users 2 Posts: 3,992 ✭✭✭Korvanica


    Malice wrote: »
    Funnily enough I think I know exactly what the problem is :).
    In your .aspx page where you have

    I think you should have


    Basically the CodeBehind attribute will cause the code in the .cs file to be compiled into an assembly whereas the CodeFile attribute will defer that until runtime which means the .cs file will be needed on the server. When you do a Publish it doesn't copy the .cs files as it thinks you don't need them. The application works locally because the .cs file exists locally.

    Bangs head off desk, multiple times.... THANK YOU!!!!!! that sorted it!!!


  • Closed Accounts Posts: 3,912 ✭✭✭HellFireClub


    Korvanica wrote: »
    Bangs head off desk, multiple times.... THANK YOU!!!!!! that sorted it!!!

    Don't you feel like dropping tools and bringing a man for a rake of pints when you get help like that?!? :D:D:D


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 15,065 ✭✭✭✭Malice


    Korvanica wrote: »
    Bangs head off desk, multiple times.... THANK YOU!!!!!! that sorted it!!!
    Glad to hear it worked. I actually had the same issue myself yesterday. A project was working fine locally but when deployed was complaining about missing .cs files. The project I'm working on was inherited from another company and they have done quite a few quirky things I haven't seen before. Using CodeFile instead of CodeBehind is just one of them.

    Take a look at the accepted answer here for a more in-depth explanation of the difference between the two attributes.
    Don't you feel like dropping tools and bringing a man for a rake of pints when you get help like that?!? :D:D:D
    On a sunny afternoon like today I'd love a few pints ;).


Advertisement