[Withvinay.com Powered By :- Vinay Sharma] DotNet Interoperability

0 views
Skip to first unread message

Vinay Sharma

unread,
Nov 28, 2011, 3:15:04 AM11/28/11
to with...@googlegroups.com

How can we use COM Components in .NET?
.NET components communicate with COM using RCW (Runtime Callable Wrapper).
Once I have developed the COM wrapper do I have to still register the COM in registry?
Yes
How can we use .NET components in COM?
.NET components can not be used in straight forward way with COM. You will need to create CCW in order that COM components communicate with .NET assemblies.
When we use windows API in .NET is it managed or unmanaged code?
Windows API in .NET is unmanaged code.
What is COM?
Microsoft's COM is a technology for component software development. It is a binary standard which is language independent. DCOM is a distributed extensio of COM.
What is Reference Counting in COM?
Reference counting is a memory management technique used to count how many times an object has a pointer referring to it. The first time it is created, the reference count is set to one. When the last reference to the object is nulled, the reference count is set to zero and the object is deleted. Care must be exercised to prevent a context switch from changing the reference count at the time of deletion.
Can you describe IUKNOWN interface in short?
Every COM object supports at least one interface, the IUNKNOWN interface. All interfaces are classes derived from the base class IUnknown. Each interface supports methods access data and perform operations transparently to the programmer. For Example, IUnknown supports three methods, AddRef,Release(), and QueryInterface().
Suppose that pinterf is a pointer to an IUnknown. pinterf->AddRef() increments the referene count.
pinterf->Release() decrements the reference count,deleting the object when the reference count reaches zero.
pinterf->QueryInterface(IDesired,pDesired) checks to see if the current interface (IUnknown) supports another interface, IDesired, creates an instance of the object if the reference count is zero and then calls pDesired->AddRef() to increment the reference count and returns the pointer to caller.
Can you Explain what is DCOM?

DCOM differs from COM in that it allows for creating objects distributed across a network, a protocol for invoking that object's methods, and secures access to the object. DCOM provides a wrapper around COM,hence it is a backwards compatible extension. DCOM uses Remote Procedure Calls(RPC) using Open Software Foundation's Distributed Computing Environment.

These RPC are implemented over TCP/IP and named pipes. The protocol which is actually being used is registered just prior to use, as opposed to being registered at initialization time. The reason for this is that if a protocol is not being used,it willnot be loaded.

In order to inform an object that the client is still alive, periodic pinging is used. Hence, when the client has died and no ping has been received before the expiration time, the server object will perform some clean up tasks.

Since RPC across a network are typically slow,DCOM sends multiple requests in the same call. For example, in COM, the program performs a QueryInterface, one interface at a time. In DCOM, multiple QueryInterfaces are all clustered into one call.

This clustering optimization trick is also used when creating an instance of the object and serializing it with data. Since these two operations usually occur together,DCOM allows one method which will perform both operations in one call without waiting for an acknowlegment from the first task before performing the second one.

Similarly, when a client pings its server object, he can do it in one call. Moreover, if there are multiple clients sending pings to multiple servers,an optimization is made where the multiple pings going to the same object are consolidated into just one ping. This is to cut down on the use of precious bandwidth used only for pinging.

The client has the control to set the computer which will be responsible for the lifetime of the object. That is to say, these objects are not created just somewhere where the system resources and access previleges allow for it.

Call Security is implemented in all four ways: authentication (to prevent false clients from impersonating the true client),authorization(to insure that a client only does what it is authorized to do),data integrity(to insure that data was not tampered with during transit) and data privacy(to insure that only designated sources can read it). The security issues are handled as they are on operating systems. The client gives the server various access privileges to access memory or disk space.
How do we create DCOM object in VB6?
Using the CreateObject method you can create a DCOM object. You have to put the server name in the registry.
How many types of Transactions are there in COM+.NET?
There are 5 transactions types that can be used with COM+. whenever an object is registered with COM+ it has to abide either to these 5 transaction types.

Disabled: There is no transaction. COM+ does not provide transaction support for this component.

Not Supported: Component does not support transactions. Hence even if the calling in the hierarchy is transaction enabled this component will not participate in the transaction

Supported: Components with transaction type support will be a part of the transaction. This will be only if the calling component has an active transaction. If the calling component is not transaction enabled this component will not start a new transaction.

Required: Components with this attribute require a transaction i.e. either the calling should have a transaction in place else this component will start a new transaction.

Required New: Components enabled with this transaction type always require a new transaction. Components with required new transaction type intantiate a new transaction for themselves every time.
How do you do object pooling in .NET?
COM+ reduces overhead by creating object from scratch. So in COM+ when object is activated its activated from pool and when its deactivated its pushed back to the pool. Object pooling is configures by using the "ObjectPoolingAttribute" to the class.
What are the types of compatability in VB6?
There are three possible project compatability settings
No Compatbility
with this setting, new clss ID's,new interface ID's and a new type library ID will be generated by VB each time the ActiveX component project is compiled. This will cause any compiled client components to fail and report a missing reference to the 'VB ActiveX Test Component' when a client project is loaded in the VB IDE

Project Compatability
With this setting, VB will generate new interface ID's for classes whose interfaces have changed,but will not change the class ID's or the type library ID. This will still cause any compiled client components to fail but will not report a missing reference to the 'VB ActiveX Test Component' when a client project is loaded in the VB IDE. Recompilation of client components will restore them to working order again.

Binary Compatability
VB makes it possible to extend an existing class or interface by adding new methods and properties etc. and yet still retain binary compatibility. It can do this, because it silently creates a new interface ID for the extended interface and adds registration code to register the original interface ID but with a new Forward key containing the valueof this new interface ID. COM will then substitute calls having the old ID with the new ID and hence applications built against the old interface will continue to work.
What is equivalent for regsvr32 exe in .NET?
Regasm


--
Posted By Vinay Sharma to Withvinay.com Powered By :- Vinay Sharma at 11/28/2011 01:45:00 PM
Reply all
Reply to author
Forward
0 new messages