How to invoke .net components from com components,give the
sequence ?

Answers were Sorted based on User's Feedback



How to invoke .net components from com components,give the sequence ? ..

Answer / shyam

The common language runtime exposes COM objects through a
proxy called the runtime callable wrapper (RCW). Although
the RCW appears to be an ordinary object to .NET clients,
its primary function is to marshal calls between a .NET
client and a COM object.

The runtime creates exactly one RCW for each COM object,
regardless of the number of references that exist on that
object. As the following illustration shows, any number of
managed clients can hold a reference to the COM objects
that expose INew and INewer interfaces. The runtime
maintains a single RCW for each object.

Using metadata derived from a type library, the runtime
creates both the COM object being called and a wrapper for
that object. Each RCW maintains a cache of interface
pointers on the COM object it wraps and releases its
reference on the COM object when the RCW is no longer
needed. The runtime performs garbage collection on the RCW.

Among other activities, the RCW marshals data between
managed and unmanaged code, on behalf of the wrapped
object. Specifically, the RCW provides marshaling for
method arguments and method return values whenever the
client and server have different representations of the
data passed between them.

The standard wrapper enforces built-in marshaling rules.
For example, when a .NET client passes a String type as
part of an argument to a managed object, the wrapper
converts the string to a BSTR type. Should the COM object
return a BSTR to its managed caller, the caller receives a
string. Both the client and the server send and receive
data that is familiar to them. Other types require no
conversion. For instance, a standard wrapper will always
pass a 4-byte integer between managed and unmanaged code
without converting the type.

Is This Answer Correct ?    1 Yes 0 No

How to invoke .net components from com components,give the sequence ? ..

Answer / shyam

When a COM client calls a .NET object, the common language
runtime creates the managed object and a COM callable
wrapper (CCW) for the object. Unable to reference a .NET
object directly, COM clients use the CCW as a proxy for the
managed object.

The runtime creates exactly one CCW for a managed object,
regardless of the number of COM clients requesting its
services. As the following illustration shows, multiple COM
clients can hold a reference to the CCW that exposes the
INew interface. The CCW, in turn, holds a single reference
to the managed object that implements the interface and is
garbage collected. Both COM and .NET clients can make
requests on the same managed object simultaneously.

COM callable wrappers are invisible to other classes
running within the .NET Framework. Their primary purpose is
to marshal calls between managed and unmanaged code;
however, CCWs also manage the object identity and object
lifetime of the managed objects they wrap.

Object Identity

The runtime allocates memory for the .NET object from its
garbage-collected heap, which enables the runtime to move
the object around in memory as necessary. In contrast, the
runtime allocates memory for the CCW from a noncollected
heap, making it possible for COM clients to reference the
wrapper directly.

Object Lifetime

Unlike the .NET client it wraps, the CCW is reference-
counted in traditional COM fashion. When the reference
count on the CCW reaches zero, the wrapper releases its
reference on the managed object. A managed object with no
remaining references is collected during the next garbage-
collection cycle.

Is This Answer Correct ?    1 Yes 0 No

How to invoke .net components from com components,give the sequence ? ..

Answer / aby

The following link provides the sequence of steps with
examples.:

http://my.execpc.com/~gopalan/dotnet/classic_com/com.net_interop.html

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More COM+ Interview Questions

what are wrapper Classes?

2 Answers   Tech Mahindra,


Is the com architecture same as .net architecture?

0 Answers  


What is scalability?

0 Answers  


Define manageability?

1 Answers  


Difference between .NET components and COM components?

3 Answers   Microsoft,






How to register com+ services?

0 Answers  


What is the new three features of COM+ services, which are not there in COM (MTS) ?

3 Answers  


Explain disadvantages of com components?

0 Answers  


What are CCW and RCW?

9 Answers   Tech Mahindra,


Can .NET Framework components use the features of Component Services?

0 Answers  


Define scalability?

2 Answers  


Define integrity?

0 Answers  


Categories