How to load the assembly at runtime in ASP.NET application.

R

Raveendra

Hi!
I am trying to create one new Application Domain and
calling one Assembly in that created Application Domain.
It is working fine with stand alone application.
But I need to do the same with ASP.NET.
In brief I will explain:
I want to create one Application domain, and call one
assembly in that created application domain, and excute
some methods/functions of that calling assembly and unload
the application domain. All these things should work with
ASP.NET. Please give your code with C#.
thanks for your help.
....Raveendra
 
N

Nicholas Paldino [.NET/C# MVP]

Raveendra,

You should be able to use the same code that you do in a console
application. However, you should make sure that the permission set which
ASP.NET is running under allows the creation of a new application domain.
The ASP.NET runtime probably does not grant full trust to the assemblies
that are running in it (for obvious reasons), the creation of a new
app-domain being one of those.

You will have to check the permissions that you are granted for ASP.NET
and change them, if possible.

Hope this helps.
 
R

Raveendra Madupu

Hi Nicholas Paldino!
Thanks for your reply. But, I could not able to success.
I am able to create new appdomain. But, I am getting error when I try to
call my assembly in the created appdomain.
I checked with the utility "fuslogvw", it is giving the error log
LOG: Processing DEVPATH.
LOG: DEVPATH is not set. Falling through to regular bind.
LOG: Attempting application configuration file download.
LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind).
LOG: Post-policy reference: MyClass, Version=1.0.1284.27980,
Culture=neutral, PublicKeyToken=null
LOG: Attempting download of new URL
file:///C:/WINNT/system32/MyClass.DLL.
LOG: Attempting download of new URL
file:///C:/WINNT/system32/MyClass/MyClass.DLL.
LOG: Attempting download of new URL
file:///C:/WINNT/system32/MyClass.EXE.
LOG: Attempting download of new URL
file:///C:/WINNT/system32/MyClass/MyClass.EXE.
LOG: All probing URLs attempted and failed.

It is seaching my assembly in the system32 folder. If I place my
assembly in that system32 folder it is working. But I need to load the
assembly in the new domain from non system folder.
How set the policy for getting the permession.
Please list out securtiy settings.
How to made this possible.
Once againg thanks for your reply.
..Raveendra
 
S

Suzanne Cook [MS]

I assume that you've set the AppDomainSetup.ApplicationBase to the
appropriate path (away from system32) when creating the AppDomain. In that
case, it sounds like the assembly is loading fine in the target appdomain,
but failing when passed back to the calling one (or, it could be that you're
not calling onto a MarshalByRefObject). Are you calling AppDomain.Load()?
That could do it. See
http://blogs.gotdotnet.com/suzcook/PermaLink.aspx/14f766a3-6944-4e67-b714-7410056564cf
for info about that and
http://blogs.gotdotnet.com/suzcook/PermaLink.aspx/b3f8138d-eecf-47c4-9055-3f6c2335f035
for info about successfully executing code in another appdomain.

Suzanne Cook
My .NET CLR Loader blog: http://blogs.gotdotnet.com/suzcook/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top