If I am using both managed and unmanaged code, can I catch exceptions generated from either managed or unmanaged code?
It doesn't matter where the exception is thrown, if there is a try..catch block to handle the exception correctly. For example, if unmanaged code is called from managed code that is protected with a try..catch, the managed code will catch any exceptions it is looking for that are thrown by the unmanaged code.
If I am using the Trace class, how do I turn off trace statements at runtime and turn them back on?
The .NET Framework provides the TraceSwitch class, which you can use not only to turn off trace statements but to turn them on with a filter for what level of trace statements you want to see. This is the elaborate solution; the other method is to simply remove the TraceListener from the Listeners collection.