Guarantee reload of assembly when change is made on network share



I am implementing a distrubuted application as a set of windows
services. A single windows service is to be installed on the
enterprise client workstations. In order to be able to maintain a
single codebase I load the code for the windows service from a network
share. I need to be able to readily replace any of the assemblies
(*.dlls) that implement the service. As a consequence, I used an
approach that I think that was initially suggested by Suzanne Cook and
loaded my application into a separate application domain (SEE CODE AT
END OF THIS MESSAGE). This approach works fine, with what appears to
be a single exception. I was debugging this service and I could not get
the VS2005 debugger to load/use the revised code (*.dll). It kept on
using the old copy. I made sure that I changed the assembly file
attribute (i.e [assembly: AssemblyFileVersion("2.0.2007.5")]) in both
the service *.exe and the *.dll in which I was implementing the code
change. I eventually found the local subdirectory that the .Net
application was using to load the code(something like
\..\LocalSettings\...\dl3). If I manually deleted this subdirectory,
then the new (revised) code loaded and I could properly debug the
application.

AND FINALLY I CAN GET TO THE POINT/Question!

This is a scientific application and I need to guarantee that when I
replace a *.dll on the file network share that the client service uses
the revised *.dll. I am assuming that it is my use of the "shadow copy"
that caused .Net to maintain the local "cached" copy on the client
workstation. Unlike most enterprise appplications, Like a lot of
programmers, I only have partial control of these departmental
workstations. I have been running this application as a
non-distrubuted application for over 2 years. In this instance since I
have total control of my servers I can easilly make changes, replace
the *.dll in the GAC , and restart the windows service. This is not
your normal enterprise application in the sense that I get changes
weekly and am normally expected to have simple model changes made and
implemented on the same day. There is some flexibility on this but not
much.


Can anyone suggest an approach that would guarantee that when I copy a
new *.dll to the network share and restart the client services (I have
the windows service "sense" the file/version change and automatically
exit and restart ). If not, I'll deep six the "shadow copy" and then
need to signal all of the workstations to stop the service prior to
making a change.


Thanks in advance

Jim Savarino
Center For Health Studies, Group Health Cooperative
savarino.je@xxxxxxx




static void Main(string[] args)
{
if (AppDomain.CurrentDomain.FriendlyName !=
m_sSHADOW_APPDOMAIN)
{
CreateShadowCopyDomain();
}
else { RunApplication(); }
}

[SecurityPermissionAttribute(SecurityAction.Assert,
ControlAppDomain = true)]
private static void CreateShadowCopyDomain()
{
AppDomain oCurrentDom = AppDomain.CurrentDomain;
AppDomainSetup oDomSetup = new AppDomainSetup();
oDomSetup.ApplicationBase =
AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
oDomSetup.ShadowCopyFiles = "true";
System.Security.PermissionSet fullTrust = new
System.Security.PermissionSet(PermissionState.Unrestricted);
fullTrust.AddPermission(new
SecurityPermission(SecurityPermissionFlag.Execution));
System.Reflection.Assembly ass =
Assembly.GetEntryAssembly();
StrongName sn = GetStrongName(ass.GetName());
AppDomain oNewDom =
AppDomain.CreateDomain(m_sSHADOW_APPDOMAIN, oCurrentDom.Evidence,
oDomSetup, fullTrust, sn);
oNewDom.ExecuteAssemblyByName( ass.FullName);
}


Jim Savarino

.



Relevant Pages

  • Reference to object in Client application
    ... windows service as host of the object and all seems to be ok. ... When I develop the client application, I need to reference the object (.dll) ...
    (microsoft.public.dotnet.framework.remoting)
  • Calling a DLL Function - Windows Server 2003
    ... I am trying to call a function in one DLL from another DLL. ... fine on workstations but is failing when the same call is made on the server. ... When called from a client running on a Windows Server 2003 using Citrix, ...
    (microsoft.public.vc.language)
  • Can I create an install package for multiple projects with VS2005?
    ... I've got a VB.NET 2005 solution composed of 3 projects a Client, ... DLL, and a Windows Service. ... I'd like to create an install package that ... I don't particularly want the Windows Service to self-register. ...
    (microsoft.public.dotnet.languages.vb)
  • RE: SBS 2003 Std & Win 2000 Pro domain client problem
    ... Thank you for posting to the SBS Newsgroup. ... I understand that there are some issues occur on two Windows 2K client ... workstations, so you want to rejoin these problematic client workstations ... We do not have a clear idea what exact issues occur on Windows 2K. ...
    (microsoft.public.windows.server.sbs)
  • RE: Client machines randomly locking up when printing
    ... I still suggest you that perform the clean boot on the problematic client ... Microsoft CSS Online Newsgroup Support ... This newsgroup only focuses on SBS technical issues. ... >> workstations XP Professional, each of the workstation links with a local ...
    (microsoft.public.windows.server.sbs)