You need to create a dynamic assembly named MyAssembly.
You also need to save the assembly to disk.
Which code segment should you use?
A.
AssemblyName myAssemblyName = new AssemblyName();
myAssemblyName.Name = “MyAssembly”;
AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Run);
myAssemblyBuilder.Save(“MyAssembly.dll”);
B.
AssemblyName myAssemblyName = new AssemblyName();
myAssemblyName.Name = “MyAssembly”;
AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Save);
myAssemblyBuilder.Save(“MyAssembly.dll”);
C.
AssemblyName myAssemblyName = new AssemblyName();
AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.RunAndSave);
myAssemblyBuilder.Save(“MyAssembly.dll”);
D.
AssemblyName myAssemblyName = new AssemblyName();
myAssemblyName.Name = (“MyAssembly”);
AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Save);
myAssemblyBuilder.Save(“c:MyAssembly.dll”);
Explanation:
Create an AssemblyName object and use it to construct an AssemblyBuilder with save privilege.
Finally call the Save method on the AssemblyBuilder to write the assembly to disk.
A Creates an assembly that does not have the privilege to save to disk.
C does not provide a name the assembly
D attempts to define a physical file location, this is not compatible with AssemblyBuilder.Save
B