3 comments

  1. I’ve got the same problem as you logged in the MSDN bug. What is the work around for this problem?

    Jason Robbins

  2. The first thing you can try is to use the upgrade wizard mentioned in the follow up posting (see above comments). If you are starting with a fresh site however, this is what’s the trick:

    Basically the trick is to use the Dependency Inversion Principle from Object Oriented Design, by not making classes depend upon each other, but let both depend upon a third abstraction (an interface for example).

    When you need to reference a specific class (page, user control etc) from the ‘Web’ section, create an Interface for the properties and methods you need to share in the ‘App_Code’ section. Then let the page or whatever derive from that Interface, thereby implementing it. When you also want to put some functionality in the Code part, you could do a base class instead of an interface.

    Example:

    Page.cs

    public class PageX : Page, ISharedStuff

    {

    public int Shared;

    }

    Code/Interfaces.cs

    public interface ISharedStuff

    {

    public int Shared;

    }

    Code/Usage.cs

    public class SomeCodeClass

    {

    // oldcode (non working because of circular dependency)

    // public DoSomething(PageX instance)

    public DoSomething(ISharedStuff instance)

    {

    DoCoolStuffWithInt(instance.Shared);

    }

    }

    I hope this makes it a bit clear… otherwise, let me know

    Raimond

Comments are closed.