User Control codebehind type not compatible with ASP type?

Discussion in 'ASP .Net' started by =?Utf-8?B?TSBL?=, Nov 22, 2004.

  1. Okay, here is my message:
    The base class includes the field 'Preview1', but its type
    (ICUser.uCtrlPreview) is not compatible with the type of control
    (ASP.previewImg_ascx).

    What I am trying to do is use a user control I created in a page. This
    control is a composite of an image and a couple of labels. I wanted include
    properties through the code behind. So I have my ascx file with it's
    codebehind file. In my ascx file I have this tag:
    <%@ Control Inherits="uCtrlPreview" src="uCtrlPreview.vb" %>

    (uCtrlPreview.vb being the codebehind)

    In my page I have these lines:
    <%@ Register TagPrefix="UserControl" TagName="PrevImg" Src="previewImg.ascx"
    %>
    ....
    <body>
    ....
    USERCONTROL:prevImg id="Preview1" runat="Server"></USERCONTROL:prevImg>

    In the codebehind for the page I have:
    Protected WithEvents Preview1 As uCtrlPreview

    So, what am I doing wrong?

    Thanks.
     
    =?Utf-8?B?TSBL?=, Nov 22, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?TSBL?=

    AbhijitSinha

    Joined:
    Nov 20, 2006
    Messages:
    1
    Parser Error

    Hey buddy !!!
    I had the same issue. Took me quite a while to work things out. Anyways check out the solution.

    It seems like there are some dll files that do not get deleted or flushed out when you try to publish to a different server ... This causes a "Type Mismatch" leading to the above issue.

    This is problem occurs because of the way in which ASP.NET 2.0 uses the application references and the folder structure of the application to compile the application. If the batch property of the <compilation> element in the web.config file for the application is set to true, ASP.NET 2.0 compiles each folder in the application into a separate assembly. In this scenario, a circular reference may occur. Additionally, the compilation process may fail if either of the following conditions is true:

    The application contains references to Web controls.
    The application contains references to Web pages that are outside the current directory.

    To resolve this problem, use one of the following methods:
    Back to the top Back to the top
    Method 1:
    Modify the web.config file
    To modify the web.config file, set the batch property of the <compilation> element in the web.config file for the application to false. Compile the application and publish it. It will work.

    Note This method is recommended only for small applications. In large production applications, when you set the batch property to false, ASP.NET 2.0 compiles each page in the application into a separate assembly. The individual page assemblies are then loaded at the next available memory location. Additionally, the individual page assemblies cannot be moved. This causes memory fragmentation.

    As a solution, you can then set the "batch" property of the <compilation> element back to true or simply remove the "batch" property from the web.config file. This causes the server to flush out the old copy of the dll files and your application will work perfectly.


    Method 2: Reorder the folders in the application
    To avoid a circular reference, reorder the folders in the application. To reorder these folders, follow these steps:
    1. Trace the references to the file and from the file that is indicated by the error message.
    2. Identify the circular reference.
    3. To avoid the circular reference, put the referenced files together in the same folder.
     
    AbhijitSinha, Nov 20, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmV6YSBOYWJp?=
    Replies:
    3
    Views:
    5,547
    =?Utf-8?B?ZWlsZWVuIG0=?=
    Jun 16, 2004
  2. Randall Parker
    Replies:
    1
    Views:
    1,965
    Islamegy®
    Oct 19, 2005
  3. John Dalberg
    Replies:
    1
    Views:
    6,413
  4. mreister
    Replies:
    1
    Views:
    3,181
    mreister
    May 25, 2010
  5. pantagruel
    Replies:
    0
    Views:
    246
    pantagruel
    Feb 17, 2006
Loading...

Share This Page