Question 1. Describe The Advantages Of Writing A Managed Code Application Instead Of Unmanaged One. What’s Involved In Certain Piece Of Code Being Managed?
The advantages include automatic garbage collection, memory management, support for versioning and security. These advantages are provided through .NET FCL and CLR, while with the unmanaged code similar capabilities had to be implemented through third-party libraries or as a part of the application itself.
Question 2. Are Com Objects Managed Or Unmanaged?
Since COM objects were written before .NET, apparently they are unmanaged.
Any code not written in the Microsoft .NET framework environment is UNMANAGED. So naturally COM+ is unmanaged because it is written in Visual Basic 6.
. NET Interview Questions
Question 3. So Can A Com Object Talk To A .net Object?
Yes, through Runtime Callable Wrapper (RCW) or PInvoke.
Question 4. How Do You Generate An Rcw From A Com Object?
Use the Type Library Import utility shipped with SDK. tlbimp COM object.dll /out:.NETobject.dll or reference the COM library from Visual Studio in your project.
MVC Framework Tutorial
Question 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.
You *can* import COM objects, even if they are not your own. It is recommended that you obtain the Primary Interop from the vendor, but not required. The most common problem importing a COM DLL is that it exposes objects that form part of a separate COM DLL. You can generate entropy for these additional DLLs, and then refer to them when importing the problem DLL.
MVC Framework Interview Questions
Question 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.
Question 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.
Microsoft Entity Framework Tutorial Microsoft Entity Framework Interview Questions
Question 8. I Want To Expose My .net Objects To Com Objects. Is That Possible?
Yes, but few things should be considered first. Classes should implement interfaces explicitly. Managed types must be public. Methods, properties, fields, and events that are exposed to COM must be public. Types must have a public default constructor with no arguments to be activated from COM. Types cannot be abstract.
Question 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.
Framework7 Interview Questions
Question 10. Suppose I Call A Com Object From A .net Application, 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.