Thanks for the information. I think that using "Work Offline" from IE is as
you stated a hack and fairly ugly for a production system, so I still want
to pursue an alternate solution. Is there any way that I can access the
Download Cache directory consistently (i.e., is there a property that
contains this path)?

When I load an Assembly over HTTP using LoadFrom(...), the Location property
of this Assembly contains a value of "c:\documents and settings\<nt
login>\local settings\application
data\assembly\dll\64d170...338e\91097def\801383...fc201\<assembly name>.dll"
which, I assume, is what is referred to as the Download Cache. This will
obviously be different on each user's PC, however, so I was hoping that the
default probing would pick it up...

So, I tried the following:
Assembly a = null;
try {
  a = Assembly.LoadFrom("http://.../<assembly name>.dll");
} catch (FileNotFoundException e) {
  // network connection unavailable
  try {
    a = Assembly.Load("<assembly name>");
  } catch (Exception x) {
    // local version not found
    throw x;
  }
}

But it seems that Assembly.Load(...) does in fact not probe the Download
Cache directory by default (unfortunately).

Thanks for the AppUpdater link -- I've looked at it, and it appears as
though it may serve my purpose. I think that the whole smart client thing is
a bit cleaner, however, and if I can just get this offline thing working
I'll be all set.

Thanks much,
joe

-----Original Message-----
From: Ian Griffiths [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 02, 2002 11:10 AM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Smart clients and offline usage


Well...  As Chris Sells pointed out, if you actually put IE into Work
Offline mode, it works fine - this seems to trap the request to the web
server and it just runs off the cached copy.

There are actually two cached copies here.  What seems to happen is that the
CLR looks at the copy in the IE cache, and if that's dated the same as the
copy in the Download Cache, it uses the version in the Download Cache.
Otherwise it will copy the copy in IE's cache into the Download Cache and
then run that.

Seems like a bit of a hack to me though.  (Personally I hate the whole work
online/offline thing.  Not least because it means I can't read my email
offline with outlook express whilst having an IE window connected to the web
server on my laptop...  Why can't it cope with partially connected
scenarios?  Or per-application online/offline settings?  But I digress...)


But in general, it looks like the smart client stuff is kind of being
rethought.  The model used by Terrarium, and the model that has been
presented at a couple of conferences doesn't use the Assembly.LoadFrom
approach.  Instead the smart client has code that manages a local cache
specific to the application (nothing to do with any of the CLR's caches).
It periodically tries to connect to the web server to check for updates.  If
it can't reach the web server it just ignores that, and carries on running
with the local copy.

I'm guessing that at some point this functionality will be built into the
CLR.  But today if you want disconnected operation but with the option to
download updates, you will need a shim application to manage this updating
for you.  Have a look at

  http://www.gotdotnet.com/team/windowsforms/appupdater.aspx

for some ideas

--
Ian Griffiths
DevelopMentor

----- Original Message -----
From: "Joe Duffy" <[EMAIL PROTECTED]>


> Ugh. So, you mean to say that, if a connection to the web server is
> unavailable, then there is no way to simply run the cached version? Is
there
> any way to instantiate or access the cached version explicitly (is it
saved
> to a visible directory, perhaps)?
>
> If not, I am thinking that the following is my best option (please provide
> any feedback):
> - If no cached assembly exists, download the entire thing (would only
happen
> the first time that the application is run), otherwise load the local
> version of the assembly from disk;
> - retrieve the "latest/current" fully qualified name of the assembly by
> executing a web service on the web server;
> - compare this to the cached assembly's fully qualified name and, if they
> are different, re-download (and cache) the assembly to disk;
> - run the application from the loaded assembly.
>
> This seems a bit labor intensive and not very performance friendly for
those
> w/out high speed connections. I was under the impression that this was
> covered by smart clients; I guess what you're saying is that only half of
it
> is -- the version management, but not offline usage.
>
> Any additional ideas would be great.
>
> Thanks!
> joe
>
> -----Original Message-----
> From: Ian Griffiths [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 01, 2002 4:21 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [ADVANCED-DOTNET] Smart clients and offline usage
>
>
> The problem is this:  when you call Assembly.LoadFrom, the loader has no
way
> of knowing if its cached copy is up to date.  So it has to go to the web
> server to check if it has changed.  If it hasn't it will then run with the
> cached copy.  Problem is, it still needs to be able to connect to the web
> server to detect a change.
>
> It's different if you do an Assembly.Load - if you pass in a
fully-qualified
> assembly name (i.e. everything - name, version, culture, public key token)
> it can know whether the version in the cache is the one you require or
not.
> (It doesn't matter if it's the latest - so long as it's what you asked for
> that'll do fine.)  And likewise with any other mechanism that passes a
> fully-qualified name into the assembly resolver, i.e. any references your
> component has to other components will typically not require a round trip
to
> the server.
>
> The problem is Assembly.LoadFrom only specifies a codebase, not a full
name.
> So it has to hit the web server to find out whether it needs to download a
> new copy.
>
>
> --
> Ian Griffiths
> DevelopMentor
>
> ----- Original Message -----
> From: "Joe Duffy" <[EMAIL PROTECTED]>
>
>
> > I am unable to find any good, thorough documentation on the
implementation
> > of smart clients (in particular, those that are offline capable). Does
> > anybody out there have internet or book references that may be helpful
in
> > this area?
> >
> > Specifically, I am able to remotely load assemblies
> > (Assembly.LoadFrom(...)), but I was under the assumption that downloaded
> > assemblies would be cached for future offline uses. When I attempt to
run
> > the application again after terminating my network connection, however,
it
> > does not pick up the cached version. Is there a separate invocation that
> > will load an assembly from cache, after which (if it fails) I can load
it
> > from the remote location? Am I limited to manually doing this? If so,
I'm
> > not sure that my technique that I have in mind is very efficient --
> > especially over a low bandwidth connection (copying the DLL locally,
> > catching "FileNotFoundException" thrown by Assembly.LoadFrom(...) to
> signify
> > lack of a network connection, and loading it from the local copy if
> > unavailable).
> >
> > Any assistance would be greatly appreciated.

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to