Documente Academic
Documente Profesional
Documente Cultură
3. So can a COM object talk to a .NET object? Yes, through Runtime Callable
Wrapper (RCW) or PInvoke.
4. How do you generate an RCW from a COM object? Use the Type Library
Import utility shipped with SDK. tlbimp COMobject.dll /out:.NETobject.dll or
reference the COM library from Visual Studio in your project.
5. I can’t import the COM object that I have on my machine. Did you write
that object? You can only import your own objects. If you need to use a COM
component from another developer, you should obtain a Primary Interop
Assembly (PIA) from whoever authored the original object.
6. How do you call unmanaged methods from your .NET code through
PInvoke? Supply a DllImport attribute. Declare the methods in your .NET
code as static extern. Do not implement the methods as they are
implemented in your unmanaged code, you’re just providing declarations for
method signatures.
7. Can you retrieve complex data types like structs from the PInvoke
calls? Yes, just make sure you re-declare that struct, so that managed code
knows what to do with it.
9. Can you inherit a COM class in a .NET application? The .NET Framework
extends the COM model for reusability by adding implementation inheritance.
Managed types can derive directly or indirectly from a COM coclass; more
specifically, they can derive from the runtime callable wrapper generated by
the runtime. The derived type can expose all the method and properties of
the COM object as well as methods and properties implemented in managed
code. The resulting object is partly implemented in managed code and partly
implemented in unmanaged code.
10. Suppose I call a COM object from a .NET applicaiton, but COM object
throws an error. What happens on the .NET end? COM methods report
errors by returning HRESULTs; .NET methods report them by throwing
exceptions. The runtime handles the transition between the two. Each
exception class in the .NET Framework maps to an HRESULT.
2. Explain consistency. We must ensure that the system is always left at the
correct state in case of the failure or success of a transaction.
4. Explain durability. Make sure that the system can return to its original state
in case of a failure.
5. Explain object pooling. With object pooling, COM+ creates objects and
keeps them in a pool, where they are ready to be used when the next client
makes a request. This improves the performance of a server application that
hosts the objects that are frequently used but are expensive to create.
10. Define scalability. The application meets its requirement for efficiency even
if the number of users increases.
12. Define availability. Users can depend on using the application when needed.