Loading assemblies from database in an ASP.NET application

Discussion in 'ASP .Net' started by Tor Bådshaug, May 21, 2008.

  1. BlankHi,
    I am having trouble loading assemblies from the database in my ASP.NET app.

    I have a default.aspx in my app that is served from a database via a custom virtual path provider. This works fine, until this
    default.aspx uses code in a dependent assembly (say CustomAssembly). Then ASP.NET cannot find the class "CustomAssembly.MyClass" and files
    to compile the default.aspx.

    I've tried to do a

    AppDomain.CurrentDomain.Load(byte[] rawAssembly)

    up front (prior to default.aspx compilation) to help ASP.NET to find this class, but the ASP.NET runtime looks to ignore it. However, I can successfully do

    AppDomain.CurrentDomain.CreateInstance("CustomAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "CustomAssembly.MyClass");

    Also, I can verify that the "CustomAssembly" is actually loaded by looking at the value of AppDomain.CurrentDomain.GetAssemblies().
    The custom assembly i loaded from database is included there, get its codebase set to something like file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary%20ASP.NET%20Files/root/300b5c74/97825cbb/assembly/dl3/95cc4ab5/aa815946_b9bac801/AppWeb.DLL

    Why does ASP.NET ignore the existence of classes that are actually loaded into the runtime and are accessible through reflection?
    Any suggestions on the next steps to achieve the dynamical loading I am seeking?
    (I need to create a sort of host application to which modules can be plugged/deployed in at runtime)

    -Tor
     
    Tor Bådshaug, May 21, 2008
    #1
    1. Advertising

  2. Tor Bådshaug

    bruce barker Guest

    to compile a page, the compiler needs read access to dll also so it can
    resolve symbols and method signatures. also the asp.net compiler has limited
    path search capabilities. in the case of non-gac assemblies, they must be in
    the bin folder.

    you could have the pages load the assemblies at runtime, and a set of
    interfaces may make this practical. i've done this before - loading the
    assembly from the database, and calling a known iteface (and sometimes used
    reflection).

    you could also do what asp.net does. create a temp folder, copy the page
    source and database dlls to the temp folder. compile the page (can use the
    aspnet_compiler), then load the compiled page assembly from the temp folder.
    (be sure to load the database dll once). this is probably the approach you
    want to do if the pages can not be precompiled.

    -- bruce (sqlwork.com)


    -- bruce (sqlwork.com)


    "Tor BÃ¥dshaug" wrote:

    > BlankHi,
    > I am having trouble loading assemblies from the database in my ASP.NET app.
    >
    > I have a default.aspx in my app that is served from a database via a custom virtual path provider. This works fine, until this
    > default.aspx uses code in a dependent assembly (say CustomAssembly). Then ASP.NET cannot find the class "CustomAssembly.MyClass" and files
    > to compile the default.aspx.
    >
    > I've tried to do a
    >
    > AppDomain.CurrentDomain.Load(byte[] rawAssembly)
    >
    > up front (prior to default.aspx compilation) to help ASP.NET to find this class, but the ASP.NET runtime looks to ignore it. However, I can successfully do
    >
    > AppDomain.CurrentDomain.CreateInstance("CustomAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "CustomAssembly.MyClass");
    >
    > Also, I can verify that the "CustomAssembly" is actually loaded by looking at the value of AppDomain.CurrentDomain.GetAssemblies().
    > The custom assembly i loaded from database is included there, get its codebase set to something like file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary%20ASP.NET%20Files/root/300b5c74/97825cbb/assembly/dl3/95cc4ab5/aa815946_b9bac801/AppWeb.DLL
    >
    > Why does ASP.NET ignore the existence of classes that are actually loaded into the runtime and are accessible through reflection?
    > Any suggestions on the next steps to achieve the dynamical loading I am seeking?
    > (I need to create a sort of host application to which modules can be plugged/deployed in at runtime)
    >
    > -Tor
    >
    >
     
    bruce barker, May 22, 2008
    #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. Timothy
    Replies:
    1
    Views:
    424
    Gaurav Khanna [C# MVP]
    Jan 27, 2004
  2. Danish Ahmed

    Dynamically Loading Assemblies in ASP.NET

    Danish Ahmed, Apr 15, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    914
    Lionel LASKE
    Apr 17, 2005
  3. Michael Gaillez

    ASP.NET and dynamically loading assemblies

    Michael Gaillez, Jun 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    406
    Oleg Ogurok
    Jun 24, 2004
  4. =?Utf-8?B?UmFuYQ==?=

    Loading Assemblies from a Newtwork PC - Web Application

    =?Utf-8?B?UmFuYQ==?=, Jun 10, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    377
    =?Utf-8?B?UmFuYQ==?=
    Jun 10, 2005
  5. WT
    Replies:
    5
    Views:
    6,212
    gerardopg
    Jun 5, 2010
Loading...

Share This Page