Exam 70-536 : .NET Framework Application Development Foundation Part – 14

Question: You need to create a class definition that is interoperable along with COM. You need to ensure that COM applications can create instances of the class and can call the GetAddress method. Which code segment should you use?

  1. public class Customer {
    string addressString;
    public Customer(string address) { addressString = address; }
    public string GetAddress() { return addressString; }}
  2. public class Customer {
    static string addressString;
    public Customer() { }
    public static string GetAddress() { return addressString; }}
  3. public class Customer {
    string addressString;
    public Customer() { }
    public string GetAddress() { return addressString; }}
  4. public class Customer {
    string addressString;
    public Customer() { }
    internal string GetAddress() { return addressString; }}

Correct Answer: 3


Question: You write the following code to call a function from the Win32 Application Programming Interface (API) by using platform invoke.
int rc = MessageBox(hWnd, text, caption, type);
You need to define a methon prototype. Which code segment should you use?

  1. [DllImport(“user32”)]
    public static extern int MessageBox(int hWnd, String text, String caption, uint type);
  2. [DllImport(“user32”)]
    public static extern int MessageBoxA(int hWnd, String text, String caption, uint type);
  3. [DllImport(“user32”)]
    public static extern int Win32API_User32_MessageBox(int hWnd, String text, String caption, uint type);
  4. [DllImport(@”C:\WINDOWS\system32\user32.dll”)]
    public static extern int MessageBox(int hWnd, String text, String caption, uint type);

Correct Answer: 1


Question: You need to create a dynamic assembly named MyAssembly. You also need to save the assembly to disk. Which code segment should you use?

  1. AssemblyName myAssemblyName = new AssemblyName();
    myAssemblyName.Name = "MyAssembly";
    AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Run);
    myAssemblyBuilder.Save("MyAssembly.dll");
  2. AssemblyName myAssemblyName = new AssemblyName();
    myAssemblyName.Name = "MyAssembly";
    AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBulderAccess.Save);
    myAssemblyBuilder.Save("MyAssembly.dll");
  3. AssemblyName myAssemblyName = new AssemblyName();
    AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.RunAndSave);
    myAssemblyBuilder.Save("MyAssembly.dll");
  4. AssemblyName myAssemblyName = new AssemblyName("MyAssembly");
    AssemblyBuilder myAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Save);
    myAssemblyBuilder.Save("c:\\MyAssembly.dll");

Correct Answer: 2


Question: You need to call an unmanaged function from your managed code by using platform invoke services. What should you do?

  1. Create a class to hold DLL functions and then create prototype methods by using managed code.
  2. Register your assembly by using COM and then reference your managed code from COM.
  3. Export a type library for your managed code.
  4. Import a type library as an assembly and then create instances of COM object.

Correct Answer: 1


Question: You are loading a new assembly into an application. You need to override the default evidence for the assembly. You require the common language runtime (CLR) to grant the assembly a permission set, as if the assembly were loaded from the local intranet zone. You need to build the evidence collection. Which code segment should you use?

  1. Evidence evidence = new Evidence(Assembly.GetExecutingAssembly().Evidence);
  2. Evidence evidence = new Evidence();
    evidence.AddAssembly(new Zone(SecurityZone.Intranet));
  3. Evidence evidence = new Evidence();
    evidence.AddHost(new Zone(SecurityZone.Intranet));
  4. Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);

Correct Answer: 3

Tagged . Bookmark the permalink.

Leave a Reply