By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,124 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,124 IT Pros & Developers. It's quick & easy.

Loading assemblies from database in an ASP.NET application

P: n/a
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("CustomAsse mbly, 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
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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("CustomAsse mbly, 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

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.