ASP.Net Runtime Hosting and finding Assemblies

R

Rick Strahl [MVP]

Hi all,

I'm building an app that uses the ASP.Net runtime...

One problem I've run into is that pages running inside of the runtime are
not finding DLLs in the GAC. In fact, if I look at the debug trace of the
search path it searches the bin directory and Temporary ASP files but not
the GAC.

A simple example I used was trying to load System.Windows.Forms. If I add a
reference to my project and make it copy local it works. If I don't do this
however and the DLL lives only in the GAC it does not.

For example, if I do:

<%@page language="C#" trace="true"%>
<%@assembly name="System.Windows.Forms"%>


When this page loads it gets:

=== Pre-bind state information ===
LOG: DisplayName = System.Windows.Forms
(Partial)
LOG: Appbase = D:\projects\AspNetHosting\bin\Debug\
LOG: Initial PrivatePath = NULL
Calling assembly : System.Web, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a.
===

LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Post-policy reference: System.Windows.Forms
LOG: Attempting download of new URL
file:///D:/projects/AspNetHosting/bin/Debug/System.Windows.Forms.DLL.
LOG: Attempting download of new URL
file:///D:/projects/AspNetHosting/bin/Debug/System.Windows.Forms/System.Windows.Forms.DLL.
LOG: Attempting download of new URL
file:///D:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/localscript/853d03f1/399ca7d6/System.Windows.Forms.DLL.
LOG: Attempting download of new URL
file:///D:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/localscript/853d03f1/399ca7d6/System.Windows.Forms/System.Windows.Form
s.DLL.
LOG: Attempting download of new URL
file:///D:/projects/AspNetHosting/bin/Debug/System.Windows.Forms.EXE.
LOG: Attempting download of new URL
file:///D:/projects/AspNetHosting/bin/Debug/System.Windows.Forms/System.Windows.Forms.EXE.
LOG: Attempting download of new URL
file:///D:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/localscript/853d03f1/399ca7d6/System.Windows.Forms.EXE.
LOG: Attempting download of new URL
file:///D:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET
Files/localscript

I've tried both custom loading (custom CreateApplicationHost()) and the
default HttpRuntime.CreateApplicationHost(). Both exhibit this same
behavior.

Anybody have any ideas how I can change it so the GAC is probed? Or maybe on
more broad terms - if I build my domain manually how does it see the GAC...

I was under the impression that no matter what the GAC would be accessed. In
this context however it appears that htis is not the case..

TIA,


+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
 
N

Natty Gur

Hi rick,

if you make reference to your own signed assembly do you still get that
error ?
I try it (System.Windows.Forms from web app) on my machine and it works.

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
 
R

Rick Strahl [MVP]

Hi Natty,

Well, from a Web app it works. It's from within the ASP.Net Runtime host
that it doesn't appear to work.

I have a page that does:

<%@page language="C#%>
<%@import assembly="system.windows.form" %>

<%
System.Windows.Form.MessageBox.Show(...);
%>

This doesn't work (can't find Windows.Forms). If I copy local then it does.
If I use my own private signed assembly and stick it in the GAC it's also
not found.
What's weird is if I use a precompiled page (with codebehind) it DOES work
(presumably because it's hard bound at compile time as opposed to the JIT
compilation at runtime).
This means that the AppDomain can get to the GAC, but it's not searching
there automaitcally if trying to dynamically locate an assembly.

Unfortunately in this case this won't work because I'm using the ASP.Net
runtime as a scripting plug in for my app.

The issue here is that the domain apparently isn't configured right so that
it finds things in the GAC...

Any ideas?

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
 
R

Rick Strahl [MVP]

Hi Natty,

Thanks for the link to the article - hadn't seen this before, but I've been
through all that long ago <g>...

The issue I have now is that the ASP.Net pages that are running are not
finding anything in the GAC. IOW, the @Import statement is finding things
fine from the bin directory but not from the GAC.

I'm not sure why this would be - I was under the impression that no matter
what the Runtime will always look in the GAC first for anything in the first
place...


+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
 
N

Natty Gur

Rick Hi,

It's interesting... can you send me sample project so I can struggle
with you...

Natty Gur[MVP]
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top