|
Some time ago Anthony Hart ("Top Ramen")
exercised his noodle and published a terrific article on "auto-deployment"
in VB.NET here on our site: http://www.eggheadcafe.com/articles/20011106.asp.
I thought it was pretty cool, but I didn't really have much need for it
as I was busy with other things. You know how sometimes things kind of
"germinate" in the back of your mind, and then all of a sudden,
they just "bloom"?
Well, not long ago a group of developers
at my company went to Redmond for ".NET readiness training".
One of the things that really stuck in my mind was what they were echoing
when they returned. "The browser is dead, the browser is dead",
they were saying. At first I thought they had just been partying a little
too much in Seattle, and I paid it no further attention.
But then, on the weekend of February 10th,
just before a trip to the Microsoft Labs myself for some scalability testing,
it all started to come together. There is a process called IEExec in the
.NET Runtime that basically allows Internet Explorer to host an Application
Domain for a trusted assembly, Windows Forms control, or even an executable
application that is loaded over the Internet or Intranet.
Anthony's article focuses on the Assembly.LoadFrom
method, using a small "loader" application to bring in the rest
of the deal. However, after doing a little study, I realized that it's
not even necessary to get that sophisticated. You can simply load an EXE
or .DLL directly from a URL or HREF, e.g.
http://www.myserver.com/apppath/appname.exe
or
<A HREF=http://www.myserver.com/apppath/appname.exe>Load
ME!<a>
Of course, the .NET
CLR must be installed on the client machine for this to work. The
key thing is understanding how to modify the security for the application
on the client so that it runs in a "Full Trust" environment.
What I'll illustrate next is not only how to do this, but also I'll give
you an actual URL to a small app that displays Mandelbrot fractals that
you can try this out on.
First, we need to go to Control Panel, Administrative
Tools, and choose Microsoft .NET Framework Configuration:
You want to choose the circled item above,
"Increase Assembly Trust". Next, we see the following screen,
"Trust an Assembly":
As can be seen from above, we can choose to make the
changes for the current user only, or for the computer (all users). Clicking
the Next button brings us to the "Which Assembly Do You Want To Trust?"
screen, and as you can see, we have the choice of a URL:
Clicking NEXT brings us to the "Choose the Minimum
Level of Trust for the Assembly" screen:
If this is a fully trusted executable or assembly, we
would move the slider up to "Full Trust", allowing the application
to perform all its desired operations without any security restrictions.
Obviously, this would be done in a secure Intranet environment or over
the Internet where we know exactly what the application is and we are
sure it's OK to run locally. Note, you may also need to adjust the Internet
Explorer Trusted Sites security level for the site URL from which you'll
be downloading and running the application.
Finally, when we click the "NEXT" button, we
get to the "Completing the Wizard" screen which summarizes the
settings, and we are done!
On the server side, the only thing that's necessary is
to open up IIS manager and ensure that the virtual folder from which the
application will be loaded does NOT have "Execute" permissions
set.
At this point, the user can bring up the URL in Internet
Explorer. They will be presented with the standard dialog asking whether
to "RUN" or "SAVE" the file, and of course, we will
choose "RUN".
And that is all there is to it! You can deploy full -
scale database - enabled multi-tier applications including related assemblies
in Internet Explorer. The best part about it is that if you've modified
or improved your application, the CLR automatically checks for updated
assemblies and will dutifully bring them over to the client machine.
And, as promised, if you want to modify your security
settings for practice, here is a link to the Mandelbrot fractal program
(it's very small, only 16K !);
Load and
run Mandelbrot Fractal in IE
Note that if you choose not to modify your settings as
described above, the app will still load and run, but it will not have
full capability. Also, you'll see a security warning balloon when it first
comes up. When the security settings have been changed to "full trust",
the warning goes away and the app has full capability. Note that because
its in a link, it will NOT come up "inside your browser". The
application actually gets installed and cached on your machine. In a production
deployment scenario, there are a number of ways that we could handle the
required security adjustments. One of the simplest is to use a small downloadable
program that the user would execute. It would make the security changes,
and then using the above technique, download and execute the main application
on the client's machine.
Where does it go? It goes in a folder that will look
like this:
C:\Documents
and Settings\YourProfile\Local Settings\Application Data\assembly\dl\a30126e061b2f0ff04a1b8d7bec7690e\530ff118\00b72f4e_8cb2c101
And, along with it will be stored
an INI file, "__AssemblyInfo__.ini", whose
content will look like this:
[AssemblyInfo]
MVID=d7b3f573c0c8e3488f28ec418b669b44
URL=http://www.eggheadcafe.com/articles/mandelbrodt.exe
DisplayName=Mandelbrodt, Version=1.0.771.31080, Culture=neutral, PublicKeyToken=null
If you are a developer working in an organization whose
job it is to develop and maintain software and client installations of
same, then you know how much of your time is spent deploying, fixing,
versioning, and maintaining your product in order to keep the end user
satisfied. The ability to deploy and maintain a full-featured Win32 application
in the manner described above should really make some lightbulbs go off
in your head!
Peter Bromberg is an independent consultant specializing in distributed .NET solutions
in Orlando and a co-developer of the EggheadCafe.com
developer website. He can be reached at pbromberg@yahoo.com
|