Assembly with USER controls (ascx) cannot find its resouces

Discussion in 'ASP .Net Building Controls' started by mschep@deloitte.nl, Mar 14, 2006.

  1. Guest

    Hi,

    I built an assembly with a set of user controls.
    This can be done with the Visual Studio 2005 Deployment Project:
    building and merging for example all your aspx and ascx in one dll
    (named BunchOfUserControls.dll)
    Doing so it's possible to resuse user controls in other web projects
    without transferring the ascx files. Just the dll.
    'The reason I need this is because I need to load dynamicly controls in
    a website.
    This works fine.
    The only thing to keep in mind is that it's not possible to use your
    own class name.
    Supose your user control is named MyNameSpace.MyUserControl the final
    dll will contain a class named ASP.<name sub folder>_MyUserControl_ascx
    This class is derived from my own class and overrides the
    FrameworkInitialize method in order to render the ascx declarative
    code.
    <name sub folder> is the folder were I've got my user controls in the
    original solution.
    So creating the user control dynamicly you need to do the following:

    Assembly assembly = Assembly.Load("BunchOfUserControls");
    object instance =
    portletAssembly.CreateInstance("ASP.mysubfolder_myusercontrol_ascx");
    myPage.Controls.Add((Control)instance);

    This works fine. The page shows correcly the user control.

    And now my problem: I need to localize my controls. Just created resx
    files for some languanges and user the same technique to create my
    assemblies.
    Web deployment project creates an assembly for the resources:
    App_LocalResources.mysubfolder.cdcab7d2.dll
    Running the system again it produces an error after adding my control
    to the page: cannot find resouce file.
    After inspecting the resource dll (with Reflector) I see all my user
    controls, however the've got the original names (MyUserControl). The
    user control dll (with Reflector) shows mysubfolder_myusercontrol_ascx.
    So I guess there is a problem matching the two.

    Is there somebody knowing how to solve this problem?

    Kind regards,

    Michel
     
    , Mar 14, 2006
    #1
    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. Replies:
    0
    Views:
    557
  2. Kris
    Replies:
    2
    Views:
    335
    Victor Bazarov
    Jan 18, 2006
  3. thunk
    Replies:
    1
    Views:
    330
    thunk
    Mar 30, 2010
  4. thunk
    Replies:
    0
    Views:
    510
    thunk
    Apr 1, 2010
  5. thunk
    Replies:
    14
    Views:
    644
    thunk
    Apr 3, 2010
Loading...

Share This Page