Home
Browse all 647 examples
Download all 647 examples
Download sample chapters
Reviews
Errata
Acknowledgments
Links on .NET
Paradoxal Press

Buy directly from Paradoxal Press at $33.99 (Save 43%)



Category: Programming
Level: Beginner to seasoned
900 pages
ISBN-10 097661322-0
ISBN-13 978-097661322-0
$59.99 USA
$79.99 CANADA


Listing 3-17 extracted from chapter Build, deploy and configure your .NET applications


Listing 3-16<     > Listing 3-18


This listing can be compiled with the command line:
csc.exe /out:MyApp.exe /target:exe Example_3_17_to_rename_MyApp.cs /r:System.dll /r:MyLib.dll /r:System.Deployment.dll
Errors: 0 Warnings: 0


Example_3_17_to_rename_MyApp.cs
using System;
using System.Reflection;
using System.Deployment.Application;
class Program {
   public static void Main() {
      AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveHandler;
      Console.WriteLine("Hello from MyApp.");
      Foo.FooFct();
   }
   static Assembly AssemblyResolveHandler(object sender, 
                                          ResolveEventArgs args) {
      if ApplicationDeployment.IsNetworkDeployed ) {
         // The 'CurrentDeployement' property returns null
         // when the application is not deployed hence the test
         // for the property 'IsNetworkDeployed'.
         ApplicationDeployment currentDeployment = 
            ApplicationDeployment.CurrentDeployment;
         currentDeployment.DownloadFileGroup("MyGroup");
         Console.WriteLine("Downloading...");
      }
      return Assembly.Load("MyLib");
   }
}
class Foo {
   public static void FooFct() {
      MyClass a = new MyClass();
      Console.WriteLine(a);
   }
}	
Copyright Patrick Smacchia 2006 2007