You are developing code for an application that retrieves information about Microsoft .NET Framework
assemblies.
The following code segment is part of the application (line numbers are included for reference only):
You need to insert code at line 04. The code must load the assembly. Once the assembly is loaded, the code
must be able to read the assembly metadata, but the code must be denied access from executing code from
the assembly.
Which code segment should you insert at line 04?
A.
Assembly.ReflectionOnlyLoadFrom(bytes);
B.
Assembly.ReflectionOniyLoad(bytes);
C.
Assembly.Load(bytes);
D.
Assembly.LoadFrom(bytes);
B
Indeed B!
Indeed B!
Indeed B!
the code must be denied access from executing code from
the assembly. makes Answer C Incorrect:
https://msdn.microsoft.com/en-us/library/0et80c7k(v=vs.110).aspx
Remarks
Dependencies are not automatically loaded into the reflection-only context.
You cannot execute code from an assembly loaded into the reflection-only context. To execute code, the assembly must be loaded into the execution context as well, using the Load method.
B
B
https://docs.microsoft.com/nl-nl/dotnet/api/system.reflection.assembly.reflectiononlyload?view=netframework-4.7.1#System_Reflection_Assembly_ReflectionOnlyLoad_System_Byte___
A is correct if you pass in the filePath directly, but instead, the methods first reads the bytes of the file.
You cannot execute code from an assembly loaded into the reflection-only context.
Assembly.ReflectionOnlyLoad Method
To execute code, the assembly must be loaded into the execution context as well, using the Load method.
B