Domain.com has given you the task of creating medical billing application that will deal with various insurance vendors.
The appropriate assemblies have to be loaded and unloaded dynamically based on the patient’s insurance provider.
All of these insurance assemblies are located in C:Insurance Assemblies.
You have to ensure that when the new application first loads, it has to load all assemblies into a separate application domain.
You need to create the child application domain and load all assemblies it using the correct code.
What should you do?
A.
Use the following code:
AppDomain domain = AppDomain.CreateDomain (“InsuranceDomain”);
foreach (string assembly in Directory.GetFiles(@”C:Insurance Assemblies”, “*.dll”))
domain.LoadAssembly (assembly);
B.
Use the following code:
AppDomain domain = AppDomain.CreateDomain (“InsuranceDomain”);
foreach (string assembly in Directory.GetFiles(@”C:Insurance Assemblies”, “*.dll”))
domain.Load (assembly);
C.
Use the following code:
AppDomain domain = AppDomain.CreateDomain (“InsuranceDomain”);
foreach (string assembly in Directory.GetFiles(@”C:Insurance Assemblies”, “*.dll”))
domain.LoadFrom (assembly);
D.
Use the following code:
AppDomain.CreateDomain (“InsuranceDomain”, Directory.GetFiles (@”C:Insurance Assemblies”, “*.dll”))
Explanation:
First, the CreateDomain method of the AppDomain class is used to create an application named InsuranceDomain.
Then, the foreach construct is used to iterate through the C:Insurance Assemblies directory
to retrieve the insurance assemblies in that location. The GetFiles method takes two String arguments, a directory path and a search string.
In this code, the GetFiles method will retrieve the names of all files in
C:Insurance Assemblies that end in .dll.
the Load method of the AppDomain class is used to load each assembly into the current application domain.
Incorrect Answers:
A, C: The LoadAssembly and LoadFrom methods do not exist in the AppDomain class.
D: The CreateDomain method does not allow the loading of assemblies into the new domain.
Correct answer is B