Re: Intermittent Referencing Bug in ASP.NET 2.0 / VS 2005



Hi Sean!

I'm pretty sure that this is not a referencing problem, since the
solution compiles if I close it down and open it. I think it's more a
bug with Studio. Thanks for your suggestions though.

There is not really any benefit in me using an Interface in what I'm
doing, since Page 1 is only ever used from Page 2, and Page 2 could use
any number of the few public properties that Page 1 exposes. I'd only
use an Interface if two pages that expose similar properties (say Page
1a and Page 1b) could lead to Page 2.

I personally don't think I've done anything that is frowned upon in my
code; it just doesn't always compile!

Thanks again!

Steve.

Sean Chambers wrote:
Do you have the <%@ Reference directive at the top of Page1.aspx
referring to the other page you want to access?

The page model in asp.net 2.0 has changed from 1.1, now you have to use
a reference directive to access other aspx pages, if you need Page1
access Page2, and Page2 to access Page1, then that would create a
circular reference, in which case you can create an interface that your
page implements and then pass the interface around instead (better idea
IMO)

hope i didn't go off base there =) Just trying to point out problems I
ran into.

Sean

steve_barker333@xxxxxxxxxxx wrote:
Hi guys!

I keep getting the following error reported by VS 2005 in my ASP.NET
2.0 web project:

"The type or namespace name 'MainPages_XXX' could not be found (are you
missing a using directive or an assembly reference?)"

The line of C# code (in the "code-behind" file) that error refers to
looks something like this:

if (Page.PreviousPage == null || !(Page.PreviousPage is MainPages_XXX))
{
//Some code....
}

For instance, the error might occur in a page called Page1.aspx (with
code behind file Page1.aspx.cs). In this page, I might refer to another
page, say Page2.aspx (code behind Page2.aspx.cs) in order to check that
the previous page was the correct type. In this particular project,
I've used folders to break up the structure of my ASP.NET pages. The
pages that are "erroring" are all in a folder called MainPages,
hence the "MainPages_" prefix, which VS 2005 has added itself. In the
cases where I get errors, both pages are in the same folder!

Closing and re-opening VS 2005 fixes the problem, but clearly, for a
large solution, that is not a viable way to get around this!

Has anyone else seen this problem? Is there a work around or a hot fix?
Is it a bad idea to refer to the type of the previous page (using
"is") in order to check how you got to the page you're on?

You help would be greatly appreciated!

Thanks in advance,

Steve.

.



Relevant Pages

  • Re: 7.0 wishlist?
    ... The "auto-implement" is intended mainly for the odd situation where an existing class you can't edit fits some interface and you're willing to take responsibility for it if it turns out not to actually adhere to the contract, and try using it where that interface type is expected. ... If reference declarations started showing up with the odd asterisk, bang, or other punctuation mark on it, but never primitive declarations, people would probably be able to guess what was going on, on the basis of "what other binary flag might be set on references but not primitives and would be really useful besides can be/cannot be null?" ... the compiler cannot prove by static analysis that the RHS isn't null might be a good idea. ... Object foo, bar; ...
    (comp.lang.java.programmer)
  • Re: Anders Hejlsberg comment on immutable objects
    ... >explicit interface implementation exists is so an interface name can class ... Improper implicit conversions constitute a nasty ... >> With value types, the variable's value is the object, not a reference ... Consider the affects of our different views on a const ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: please try this program (generic resolution)
    ... of the specific interfaces of a generic interface that has that name and ... either is in the scoping unit in which the reference appears or is made ... And now in my example I misspelled ENISOC. ... external fun ...
    (comp.lang.fortran)
  • Re: Referencing your other assemblies in projects
    ... Yeah, I know it seems weird, but I still put winforms applications under the ... I set the working folder ... My company sets up a "Release" folder for commonly used assemblies. ... the dietcoke manager can relatively reference ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# Plugin system - same interface in two different assemblies...
    ... "add a reference to the appropriate assemblies to each and every project"? ... You don't have each plugin project deciding what ... its idea of the interface is. ... can't by forcing people to include them in assemblies as I've explained. ...
    (microsoft.public.dotnet.languages.csharp)

Loading