C# Class NavHelper.AssemblyResolver.AssemblyResolver

Helper class for Microsoft Dynamics NAV that allows C/AL to receive the AssemblyResolve event and process it at runtime. The class subscribes to the AssemblyResolve event of the current application domain at startup, and upon disposal it unsubscribes from events. The class uses a common assembly repository that will be created once per service tier instance runtime, but each session will be able to resolve an assembly independently. Assemblies resolved in one session will be available to other sessions.
Inheritance: IDisposable
显示文件 Open project: vjekob/NAV-Assembly-Resolver

Public Methods

Method Description
AssemblyResolver ( ) : System

Constructor. It adds this instance of the AssemblyResolver to the static list of resolvers, and then attempts to subscribe this instance to the AssemblyResolve event of the current application domain.

ResolveAssembly ( string name, byte asm, byte pdb ) : void

Stores the assembly in the instance cache.

Private Methods

Method Description
AssemblyResolve ( object sender, ResolveEventArgs args ) : Assembly
GetExceptionMessage ( Exception e, string method ) : string
IDisposable ( ) : void

Implements the IDisposable interface. It first unsubscribes current instance from listening to the ApplicationResolve event of the current application domain (if this instance was subscribed to it), then removes this instance from the static list of AssemblyResolver instances, and then subscribes the next instance from the list if there are any left. This makes sure that there is always one and only one instance of the AssemblyResolver subscribed to the AssemblyResolve event of the current application domain, and that any instances belonging to ended sessions are unsubscribed so that they may be garbage-collected.

Subscribe ( ) : void

Subscribes this instance of AssemblyResolver to the AssemblyResolve event of the current application domain if no other instance of AssemblyResolver is already subscribed to that event.

Unsubscribe ( ) : void

Unsubscribes this instance of AssemblyResolver from the AssemblyResolve event of the current application domain if this instance was subscribed to it.

Method Details

AssemblyResolver() public method

Constructor. It adds this instance of the AssemblyResolver to the static list of resolvers, and then attempts to subscribe this instance to the AssemblyResolve event of the current application domain.
public AssemblyResolver ( ) : System
return System

ResolveAssembly() public method

Stores the assembly in the instance cache.
public ResolveAssembly ( string name, byte asm, byte pdb ) : void
name string Fully qualified name of the assembly to store in the instance cache.
asm byte Byte array containing the assembly bytes to store in the instance cache.
pdb byte Byte array containing the debug information for the assembly.
return void