Re: CodeFile - or a bug in VS?

Tech-Archive recommends: Fix windows errors by optimizing your registry



re:
!> 2/ I compile project (no changes made - just compile what VS 2008 generated.
!> Compilation is OK

That's my experience, too.

When you say "compile project", do you mean select the "Build" menu item
in the IDE and click on the Build "name_of_your_project" link ?

re:
!> 3/ I run the project and I get the runtime error as I mentioned in my previous messages.

What do you mean by "I run the project" ?

What happens when you select "default.aspx" in the Solution Explorer,
right-click it and select "View in Browser" ?

Or...what happens when you open default.aspx for editing, right-click
the body of "default.aspx" in the IDE, and select "View in Browser" ?





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
=========================
"Lubomir" <Lubomir@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7C9DE36C-4624-42CC-A028-ED9B05E4D983@xxxxxxxxxxxxxxxx
I didn't put the project on IIS yet. I just generated a new project from VS
2008 template "ASP.NET Web Application".

1/ Page declaration has attribute CodeBehind and Inherit
(I think when the Codebehind is use, the other attribute should be Src, not
Inherit. I am not sure about that, however.
2/ I compila project (no chnages made - just compile what VS 2008 generated.
Compilation is OK
3/ I run the projetc and I get the runtime error as I mentioned in my
previous messages.
4/ I change CodeBehind to CodeFile. Compilation is fine, and NO runtime
errors anymore.

I am wondering why is this happenning. I tried the same steps on more
machines and I get the same results.

/Lubomir

"Mark Fitzpatrick" wrote:

Does it fully compile without error? Also, is the root of your site marked
as an application in the web server?

This is not a bug that you are seeing. CodeFile means compile at runtime and
your page will behave like a web site project instead of the web application
project. Usually I see this in one of two scenarios.

1) The app was compiled but failed to compile and we didn't notice. If it
fails to compile you'll get this error.
2) your project directory isn't marked an application. If the app is in
c:\inetpub\wwwroot\myapp (for example) and you haven't gone into the IIS
properties and marked myapp as an application, then you'll get this error
because the dll is in the wrong spot. Since myapp ins't marked an
application, it looks for the closest one up the chain which would be in
wwwroot and that's where it would expect the dll to be in the wwwroot\bin
directory and not the wwwroot\myapp\bin directory.

Can you give a bit more info on the setup since it could be your
configuration that's the issue.

Hope this helps,
Mark Fitzpatrick


"Lubomir" <Lubomir@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:893902A4-B365-4955-9334-E241AE646D08@xxxxxxxxxxxxxxxx
Yes, I have that namespace. Also partial class name is correct.
And when I change CodeBehind attribute to CodeFile, everything starts work
fine.



"Juan T. Llibre" wrote:

Question...

In Default.aspx.cs, do you have a namespace declaration like this one ?


namespace Test
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
=========================
"Lubomir" <Lubomir@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B0A2B888-3F5A-41DB-AB56-67E937F8F118@xxxxxxxxxxxxxxxx
I created a project:
Create ->project->Visual C#->Web->ASP.NET Application

This will create a VS project (not a web site) as expected.
The default page has a page declaration:

<%@ Page Language="C#" AutoEventWireUp="true"
CodeBehind="Default.aspx.cs"
Inherits="Test._Default" %>

1/ I compile aproject, as it was generated - no changes made in it
2/ I run the project = I get an error:

"Server Error in '/' Application
Parser Error
Description: An error occured during the parsing of a resource required
to
service this request. Please review the following specific parse error
and
details and modify your source code appropriatelly.

Parser Error Message: Could not load type "Test._Default"

When I change generated attribute CodeBehind to CodeFile (I don't do
any
other changes) everything works fine.

That's I wonder if it is a bug in a code generation.
To Jonathan: By "This attribute should not be there" I ment, the
attribute
CodeFile should be generated isntead of the CodeBehind attribute.

Thanks for your time,
Lubomir


"Juan T. Llibre" wrote:

If you create a new Web Application, the page declaration looks like
this :

<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>

That's OK...and will compile without problems.

If you create a new Web Project, the page declaration looks like this
:

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>

That will also compile without problems.

There's no bug...just different declarations for different
types of VS applications ( "web project" vs. "web application" ).





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
=========================
"Lubomir" <Lubomir@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CCAFEBBE-78A3-4632-95FA-1C46E118768D@xxxxxxxxxxxxxxxx
Hi,

I am using VS 2008. and a project target platform is .NET 3.5. When
I create
a new web app project, the VS generates a default asp page, with the
page
directive. There is an attribute Inherits as expected and an
attribute
CodeBehind. This attribute should not be there,the CodeFile should
be used
instead. I have to change it manualy, otherwise I get a runtime
server error.

Is this a bug in VS 2008 or am I missing something? I have patched
OS and VS.

Thank you for help,
Lubomir













.



Relevant Pages

  • Re: CodeFile - or a bug in VS?
    ... CodeFile should be generated isntead of the CodeBehind attribute. ... That's OK...and will compile without problems. ... If you create a new Web Project, the page declaration looks like this: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: CodeFile - or a bug in VS?
    ... 1/ Page declaration has attribute CodeBehind and Inherit ... 4/ I change CodeBehind to CodeFile. ... The app was compiled but failed to compile and we didn't notice. ... do you have a namespace declaration like this one? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: CodeFile - or a bug in VS?
    ... This is not a bug that you are seeing. ... CodeFile means compile at runtime and your page will behave like a web site project instead of the web application project. ... do you have a namespace declaration like this one? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: What is the difference detween SRC and CODEBEHIND Tags?
    ... >> dynamically compile when the page is requested. ... >> CODEBEHIND specifies the name of the compiled file that contains the ... It tells the designer where to find the ... >> work with at design time. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: CodeFile - or a bug in VS?
    ... Juan T. Llibre, asp.net MVP ... 1/ Page declaration has attribute CodeBehind and Inherit ... The app was compiled but failed to compile and we didn't notice. ...
    (microsoft.public.dotnet.framework.aspnet)