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

Question: You are developing an application that dynamically loads assemblies from an application directory. You need to write a code segment that loads an assembly named Company1.dll into the current application domain. Which code segment should you use?

  1. AppDomain domain = AppDomain.CurrentDomain;
    string myPath = Path.Combine(domain.BaseDirectory, "Company1.dll");
    Assembly asm = Assembly.LoadFrom(myPath);
  2. AppDomain domain = AppDomain.CurrentDomain;
    string myPath = Path.Combine(domain.BaseDirectory, "Company1.dll");
    Assembly asm = Assembly.Load(myPath);
  3. AppDomain domain = AppDomain.CurrentDomain;
    string myPath = Path.Combine(domain.DynamicDirectory, "Company1.dll");
    Assembly asm = AppDomain.CurrentDomain.Load(myPath);
  4. AppDomain domain = AppDomain.CurrentDomain;
    Assembly asm = domain.GetData("Company1.dll");

Correct Answer: 1


Question: You are creating a class that uses unmanaged resources. This class maintains references to managed resources on other objects. You need to ensure that users of this class can explicitly release resources when the class instance ceases to be needed. Which three actions should you perform? (Each correct answer presents part of the solution. Choose three.)

  1. Define the class such that it inherits from the WeakReference class.
  2. Define the class such that it implements the IDisposable interface.
  3. Create a class destructor that calls methods on other objects to release the managed resources.
  4. Create a class destructor that releases the unmanaged resources.
  5. Create a Dispose method that calls System.GC.Collect to force garbage collection.
  6. Create a Dispose method that releases unmanaged resources and calls methods on other objects to release the managed resources.

Correct Answer: 2, 4 & 6


Question: You write a class named Employee that includes the following code segment.
public class Employee
{
string employeeId, employeeName, jobTitleName;
public string GetName()
{
return employeeName;
}
public string GetTitle()
{
return jobTitleName;
}
}

You need to expose this class to COM in a type library. The COM interface must also facilitate forward-compatibility across new versions of the Employee class. You need to choose a method for generating the COM interface. What should you do?

  1. Add the following attribute to the class definition.
    [ClassInterface(ClassInterfaceType.None)]
    public class Employee {
  2. Add the following attribute to the class definition.
    [ClassInterface(ClassInterfaceType.AutoDual)]
    public class Employee {
  3. Add the following attribute to the class definition.
    [ComVisible(true)]
    public class Employee {
  4. Define an interface for the class and add the following attribute to the class
    definition.
    [ClassInterface(ClassInterfaceType.None)]
    public class Employee : IEmployee {

Correct Answer: 4


Question: You use Reflection to obtain information about a method named MyMethod. You need to ascertain whether MyMethod is accessible to a derived class. What should you do?

  1. Call the IsAssembly property of the MethodInfo class.
  2. Call the IsVirtual property of the MethodInfo class.
  3. Call the IsStatic property of the MethodInfo class.
  4. Call the IsFamily property of the MethodInfo class.

Correct Answer: 4


Question: You write the following code segment to call a function from the Win32 Application Programming Interface (API) by using platform invoke.
string personName = "N?el";
string msg = "Welcome" + personName + "to club"!";
bool rc = User32API.MessageBox(0, msg, personName, 0);

You need to define a method prototype that can best marshal the string data. Which code segment should you use?

  1. [DllImport("user32", CharSet = CharSet.Ansi)]
    public static extern bool MessageBox(int hWnd, string text, string caption, uint type);
    }
  2. [DllImport("user32", EntryPoint = "MessageBoxA", CharSet = CharSet.Ansi)]
    public static extern bool MessageBox(int hWnd, [MarshalAs(UnmanagedType.LPWStr)]string text, [MarshalAs(UnmanagedType.LPWStr)]string caption, uint type);
    }
  3. [DllImport("user32", CharSet = CharSet.Unicode)]
    public static extern bool MessageBox(int hWnd, string text, string caption, uint type);
    }
  4. [DllImport("user32", EntryPoint = "MessageBoxA", CharSet = CharSet.Unicode)]
    public static extern bool MessageBox(int hWnd, [MarshalAs(UnmanagedType.LPWStr)]string text, [MarshalAs(UnmanagedType.LPWStr)]string caption, uint type);
    }

Correct Answer: 3

Tagged . Bookmark the permalink.

Leave a Reply