Sunteți pe pagina 1din 11

Remoting Questions

What distributed process frameworks outside .NET do you know?


Distributed Computing Environment/Remote Procedure Calls (DEC/RPC), Microsoft Distributed Component Object
Model (DCOM), Common Object Request Broker Architecture (CORBA), and Java Remote Method Invocation (RMI).

What are possible implementations of distributed applications in .NET?


.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in
System.Runtime.Remoting and System.Web.Services.

When would you use .NET Remoting and when Web services?
Use remoting for more efficient exchange of information when you control both ends of the application. Use Web
services for open-protocol-based information exchange when you are just a client or a server with the other end
belonging to someone else.

What's a proxy of the server object in .NET Remoting?


It's a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the
communication between real server object and the client object. This process is also known as marshaling.

What are remotable objects in .NET Remoting?


Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value,
where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference,
where just a reference to an existing object is passed.

What are channels in .NET Remoting?


Channels represent the objects that transfer the other serialized objects from one application domain to another and
from one computer to another, as well as one process to another on the same box. A channel must exist before an
object can be transferred.
What security measures exist for .NET Remoting in System.Runtime.Remoting?
None. Security should be taken care of at the application level. Cryptography and other security techniques can be
applied at application or server level.

What is a formatter?
A formatter is an object that is responsible for encoding and serializing data into messages on one end, and
deserializing and decoding messages into data on the other end.

Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs?

Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.

What's SingleCall activation mode used for?


If the server object is instantiated for responding to just one single request, the request should be made in SingleCall
mode.

What's Singleton activation mode?


A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by
lifetime lease.

How do you define the lease of the object?


By implementing ILease interface when writing the class code.

Can you configure a .NET Remoting object via XML file?


Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings
take precedence over machine.config.

How can you automatically generate interface for the remotable object in .NET with Microsoft tools?
Use the Soapsuds tool.

What are CAO's i.e. Client Activated Objects ?


Client-activated objects are objects whose lifetimes are controlled by the calling application domain, just as they
would be if the object were local to the client. With client activation, a round trip to the server occurs when the client
tries to create an instance of the server object, and the client proxy is created using an object reference (ObjRef)
obtained on return from the creation of the remote object on the server. Each time a client creates an instance of a
client-activated type, that instance will service only that particular reference in that particular client until its lease
expires and its memory is recycled. If a calling application domain creates two new instances of the remote type,
each of the client references will invoke only the particular instance in the server application domain from which the
reference was returned.
In COM, clients hold an object in memory by holding a reference to it. When the last client releases its last reference,
the object can delete itself. Client activation provides the same client control over the server object's lifetime, but
without the complexity of maintaining references or the constant pinging to confirm the continued existence of the
server or client. Instead, client-activated objects use lifetime leases to determine how long they should continue to
exist. When a client creates a remote object, it can specify a default length of time that the object should exist. If the
remote object reaches its default lifetime limit, it contacts the client to ask whether it should continue to exist, and if
so, for how much longer. If the client is not currently available, a default time is also specified for how long the server
object should wait while trying to contact the client before marking itself for garbage collection. The client might even
request an indefinite default lifetime, effectively preventing the remote object from ever being recycled until the server
application domain is torn down. The difference between this and a server-activated indefinite lifetime is that an
indefinite server-activated object will serve all client requests for that type, whereas the client-activated instances
serve only the client and the reference that was responsible for their creation. For more information, see Lifetime
Leases.
To create an instance of a client-activated type, clients either configure their application programmatically (or using a
configuration file) and call new (New in Visual Basic), or they pass the remote object's configuration in a call to
Activator.CreateInstance. The following code example shows such a call, assuming a TcpChannel has been
registered to listen on port 8080.

How many processes can listen on a single TCP/IP port?


One.

What technology enables out-of-proc communication in .NET?


Most usually Remoting;.NET remoting enables client applications to use objects in other processes on the same
computer or on any other computer available on its network.While you could implement an out-of-proc component in
any number of other ways, someone using the term almost always means Remoting.

How can objects in two diff. App Doimains communicate with each other?
.Net framework provides various ways to communicate with objects in different app domains.
First is XML Web Service on internet, its good method because it is built using HTTP protocol and SOAP formatting.
If the performance is the main concern then go for second option which is .Net remoting because it gives you the
option of using binary encoding and the default TcpChannel, which offers the best interprocess communication
performance
What is the difference between .Net Remoting and Web Services?
Although we can develop an application using both technologies, each of them has its distinct advantages. Yes you
can look at them in terms of performance but you need to consider your need first. There are many other factors such
authentications, authorizing in process that need to be considered.
Point Remoting Webservices
If your application needs
Yes, Choose Web Services
interoperability with other No because it is more flexible in that
platforms or operating they are support SOAP.
systems
If performance is the main You should use the TCP channel and
No
requirement with security the binary formatter
Complex Programming Yes No
Supports a range of state Its stateless service
management, depending on what management (does not inherently
State Management
object lifetime scheme you choose correlate multiple calls from the
(single call or singleton call). same user)
It can access through TCP or HTTP It can be access only through
Transport Protocol
channel. HTTP channel.

WebServices And Windows Services


Next>>
Can you give an example of when it would be appropriate to use a web service as opposed
to non-serviced .NET component
Web service is one of main component in Service Oriented Architecture. You could use web
services when your clients and servers are running on different networks and also different
platforms. This provides a loosely coupled system. And also if the client is behind the firewall it
would be easy to use web service since it runs on port 80 (by default) instead of having some
thing else in Service Oriented Architecture applications.
What is the standard you use to wrap up a call to a Web service
"SOAP.
"
What is the transport protocol you use to call a Web service SOAP
HTTP with SOAP

What does WSDL stand for?


"WSDL stands for Web Services Dsescription Langauge. There is WSDL.exe that creates a .wsdl
Files which defines how an XML Web service behaves and instructs clients as to how to interact
with the service.
eg: wsdl http://LocalHost/WebServiceName.asmx"

Where on the Internet would you look for Web Services?


www.uddi.org

What does WSDL stand for?


Web Services Description Language

True or False: To test a Web service you must create a windows application or Web
application to consume this service?
False.

What are the various ways of accessing a web service ?


1.Asynchronous Call
Application can make a call to the Webservice and then continue todo watever oit wants to
do.When the service is ready it will notify the application.Application can use BEGIN and END
method to make asynchronous call to the webmethod.We can use either a WaitHandle or a
Delegate object when making asynchronous call.
The WaitHandle class share resources between several objects. It provides several methods
which will wait for the resources to become available
The easiest and most powerful way to to implement an asynchronous call is using a delegate
object. A delegate object wraps up a callback function. The idea is to pass a method in the
invocation of the web method. When the webmethod has finished it will call this callback function
to process the result

2.Synchronous Call
Application has to wait until execution has completed.

What are VSDISCO files?


VSDISCO files are DISCO files that support dynamic discovery of Web services. If you place the
following VSDISCO file in a directory on your Web server, for example, it returns references to
all ASMX and DISCO files in the host directory and any subdirectories not noted in
<EXCLUDE>elements:

<DYNAMICDISCOVERY
xmlns="urn:schemas-dynamicdiscovery:disco.2000-03-17">
<EXCLUDE path="_vti_cnf" />
<EXCLUDE path="_vti_pvt" />
<EXCLUDE path="_vti_log" />
<EXCLUDE path="_vti_script" />
<EXCLUDE path="_vti_txt" />
</DYNAMICDISCOVERY>

How does dynamic discovery work?


ASP.NET maps the file name extension VSDISCO to an HTTP handler that scans the host
directory and subdirectories for ASMX and DISCO files and returns a dynamically generated
DISCO document. A client who requests a VSDISCO file gets back what appears to be a static
DISCO document.

Note that VSDISCO files are disabled in the release version of ASP.NET. You can reenable them
by uncommenting the line in the <HTTPHANDLERS>section of Machine.config that maps
*.vsdisco to System.Web.Services.Discovery.DiscoveryRequestHandler and granting the
ASPNET user account permission to read the IIS metabase. However, Microsoft is actively
discouraging the use of VSDISCO files because they could represent a threat to Web server
security.

Is it possible to prevent a browser from caching an ASPX page?


Just call SetNoStore on the HttpCachePolicy object exposed through the Response object's
Cache property, as demonstrated here:

<%@ Page Language="C#" %>

<%
Response.Cache.SetNoStore ();
Response.Write (DateTime.Now.ToLongTimeString ());
%>

SetNoStore works by returning a Cache-Control: private, no-store header in the HTTP response.
In this example, it prevents caching of a Web page that shows the current time.

What does AspCompat="true" mean and when should I use it?


AspCompat is an aid in migrating ASP pages to ASPX pages. It defaults to false but should be set
to true in any ASPX file that creates apartment-threaded COM objects--that is, COM objects
registered ThreadingModel=Apartment. That includes all COM objects written with Visual Basic
6.0. AspCompat should also be set to true (regardless of threading model) if the page creates
COM objects that access intrinsic ASP objects such as Request and Response. The following
directive sets AspCompat to true:
<%@ Page AspCompat="true" %>
Setting AspCompat to true does two things. First, it makes intrinsic ASP objects available to
the COM components by placing unmanaged wrappers around the equivalent ASP.NET objects.
Second, it improves the performance of calls that the page places to apartment- threaded COM
objects by ensuring that the page (actually, the thread that processes the request for the page)
and the COM objects it creates share an apartment. AspCompat="true" forces ASP.NET request
threads into single-threaded apartments (STAs). If those threads create COM objects marked
ThreadingModel=Apartment, then the objects are created in the same STAs as the threads that
created them. Without AspCompat="true," request threads run in a multithreaded apartment
(MTA) and each call to an STA-based COM object incurs a performance hit when it's marshaled
across apartment boundaries.
Do not set AspCompat to true if your page uses no COM objects or if it uses COM objects that
don't access ASP intrinsic objects and that are registered ThreadingModel=Free or
ThreadingModel=Both.

Can two different programming languages be mixed in a single ASMX file?


No.

What namespaces are imported by default in ASMX files?


The following namespaces are imported by default. Other namespaces must be imported
manually.· System, System.Collections,System.ComponentModel,System.Data,
System.Diagnostics,System.Web,System.Web.Services
How do I provide information to the Web Service when the information is required as a SOAP
Header?
The key here is the Web Service proxy you created using wsdl.exe or through Visual Studio
.NET's Add Web Reference menu option. If you happen to download a WSDL file for a Web
Service that requires a SOAP header, .NET will create a SoapHeader class in the proxy source
file. Using the previous example:
public class Service1 : System.Web.Services.Protocols.SoapHttpClientProtocol
{
public AuthToken AuthTokenValue;

[System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/",
IsNullable=false)]
public class AuthToken : SoapHeader { public string Token; }}

In this case, when you create an instance of the proxy in your main application file, you'll also
create an instance of the AuthToken class and assign the string:
Service1 objSvc = new Service1();
processingobjSvc.AuthTokenValue = new AuthToken();
objSvc.AuthTokenValue.Token = <ACTUAL token value>;
Web Servicestring strResult = objSvc.MyBillableWebMethod();

What is WSDL?
WSDL is the Web Service Description Language, and it is implemented as a specific XML
vocabulary. While it's very much more complex than what can be described here, there are two
important aspects to WSDL with which you should be aware. First, WSDL provides instructions to
consumers of Web Services to describe the layout and contents of the SOAP packets the Web
Service intends to issue. It's an interface description document, of sorts. And second, it isn't
intended that you read and interpret the WSDL. Rather, WSDL should be processed by machine,
typically to generate proxy source code (.NET) or create dynamic proxies on the fly (the SOAP
Toolkit or Web Service Behavior).

What is a Windows Service and how does its lifecycle differ from a "standard" EXE?
Windows service is a application that runs in the background. It is equivalent to a NT service.
The executable created is not a Windows application, and hence you can't just click and run it . it
needs to be installed as a service, VB.Net has a facility where we can add an installer to our
program and then use a utility to install the service. Where as this is not the case with standard
exe

How can a win service developed in .NET be installed or used in Win98?


Windows service cannot be installed on Win9x machines even though the .NET framework runs
on machine.
Can you debug a Windows Service? How ?
Yes we can debug a Windows Service.
Attach the WinDbg debugger to a service after the service starts
This method is similar to the method that you can use to attach a debugger to a process and then
debug a process.
Use the process ID of the process that hosts the service that you want to debug
1 To determine the process ID (PID) of the process that hosts the service that you want to debug,
use one of the following methods.
• Method 1: Use the Task Manager
a. Right-click the taskbar, and then click Task Manager. The Windows Task Manager dialog box
appears.
b. Click the Processes tab of the Windows Task Manager dialog box.
c. Under Image Name, click the image name of the process that hosts the service that you want
to debug. Note the process ID of this process as specified by the value of the corresponding PID
field.
• Method 2: Use the Task List Utility (tlist.exe)
a. Click Start, and then click Run. The Run dialog box appears.
b. In the Open box, type cmd, and then click OK.
c. At the command prompt, change the directory path to reflect the location of the tlist.exe file on
your computer.

Note The tlist.exe file is typically located in the following directory: C:\Program Files\Debugging
Tools for Windows
d. At the command prompt, type tlist to list the image names and the process IDs of all
processes that are currently running on your computer.

Note Make a note of the process ID of the process that hosts the service that you want to
debug.
2 At a command prompt, change the directory path to reflect the location of the windbg.exe file on
your computer.

Note If a command prompt is not open, follow steps a and b of Method 1. The windbg.exe file is
typically located in the following directory: C:\Program Files\Debugging Tools for Windows.
3 At the command prompt, type windbg –p ProcessID to attach the WinDbg debugger to the
process that hosts the service that you want to debug.

Note ProcessID is a placeholder for the process ID of the process that hosts the service that you
want to debug.

Use the image name of the process that hosts the service that you want to debug

You can use this method only if there is exactly one running instance of the process that hosts the
service that you want to run. To do this, follow these steps:
1 Click Start, and then click Run. The Run dialog box appears.
2 In the Open box, type cmd, and then click OK to open a command prompt.
3 At the command prompt, change the directory path to reflect the location of the windbg.exe file
on your computer.

Note The windbg.exe file is typically located in the following directory: C:\Program
Files\Debugging Tools for Windows.
4 At the command prompt, type windbg –pn ImageName to attach the WinDbg debugger to the
process that hosts the service that you want to debug.

NoteImageName is a placeholder for the image name of the process that hosts the service that
you want to debug. The "-pn" command-line option specifies that the ImageName command-line
argument is the image name of a process.
back to the top
Start the WinDbg debugger and attach to the process that hosts the service that you want to
debug

1 Start Windows Explorer.


2 Locate the windbg.exe file on your computer.

Note The windbg.exe file is typically located in the following directory: C:\Program
Files\Debugging Tools for Windows
3 Run the windbg.exe file to start the WinDbg debugger.
4 On the File menu, click Attach to a Process to display the Attach to Process dialog box.
5 Click to select the node that corresponds to the process that hosts the service that you want to
debug, and then click OK.
6 In the dialog box that appears, click Yes to save base workspace information. Notice that you
can now debug the disassembled code of your service.
Configure a service to start with the WinDbg debugger attached
You can use this method to debug services if you want to troubleshoot service-startup-related
problems.
1 Configure the "Image File Execution" options. To do this, use one of the following methods:
• Method 1: Use the Global Flags Editor (gflags.exe)
a. Start Windows Explorer.
b. Locate the gflags.exe file on your computer.

Note The gflags.exe file is typically located in the following directory: C:\Program
Files\Debugging Tools for Windows.
c. Run the gflags.exe file to start the Global Flags Editor.
d. In the Image File Name text box, type the image name of the process that hosts the service
that you want to debug. For example, if you want to debug a service that is hosted by a process
that has MyService.exe as the image name, type MyService.exe.
e. Under Destination, click to select the Image File Options option.
f. Under Image Debugger Options, click to select the Debugger check box.
g. In the Debugger text box, type the full path of the debugger that you want to use. For
example, if you want to use the WinDbg debugger to debug a service, you can type a full path
that is similar to the following: C:\Program Files\Debugging Tools for Windows\windbg.exe
h. Click Apply, and then click OK to quit the Global Flags Editor.
• Method 2: Use Registry Editor
a. Click Start, and then click Run. The Run dialog box appears.
b. In the Open box, type regedit, and then click OK to start Registry Editor.
c. Warning If you use Registry Editor incorrectly, you may cause serious problems that may
require you to reinstall your operating system. Microsoft cannot guarantee that you can solve
problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.

In Registry Editor, locate, and then right-click the following registry subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File
Execution Options
d. Point to New, and then click Key. In the left pane of Registry Editor, notice that New Key #1
(the name of a new registry subkey) is selected for editing.
e. Type ImageName to replace New Key #1, and then press ENTER.

Note ImageName is a placeholder for the image name of the process that hosts the service that
you want to debug. For example, if you want to debug a service that is hosted by a process that
has MyService.exe as the image name, type MyService.exe.
f. Right-click the registry subkey that you created in step e.
g. Point to New, and then click String Value. In the right pane of Registry Editor, notice that New
Value #1, the name of a new registry entry, is selected for editing.
h. Replace New Value #1 with Debugger, and then press ENTER.
i. Right-click the Debugger registry entry that you created in step h, and then click Modify. The
Edit String dialog box appears.
j. In the Value data text box, type DebuggerPath, and then click OK.

Note DebuggerPath is a placeholder for the full path of the debugger that you want to use. For
example, if you want to use the WinDbg debugger to debug a service, you can type a full path
that is similar to the following: C:\Program Files\Debugging Tools for Windows\windbg.exe
2 For the debugger window to appear on your desktop, and to interact with the debugger, make
your service interactive. If you do not make your service interactive, the debugger will start but
you cannot see it and you cannot issue commands. To make your service interactive, use one of
the following methods:
• Method 1: Use the Services console
a. Click Start, and then point to Programs.
b. On the Programs menu, point to Administrative Tools, and then click Services. The Services
console appears.
c. In the right pane of the Services console, right-click ServiceName, and then click Properties.

Note ServiceName is a placeholder for the name of the service that you want to debug.
d. On the Log On tab, click to select the Allow service to interact with desktop check box under
Local System account, and then click OK.
• Method 2: Use Registry Editor
a. In Registry Editor, locate, and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName
Note Replace ServiceName with the name of the service that you want to debug. For example,
if you want to debug a service named MyService, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService
b. Under the Name field in the right pane of Registry Editor, right-click Type, and then click
Modify. The Edit DWORD Value dialog box appears.
c. Change the text in the Value data text box to the result of the binary OR operation with the
binary value of the current text and the binary value, 0x00000100, as the two operands. The
binary value, 0x00000100, corresponds to the SERVICE_INTERACTIVE_PROCESS constant
that is defined in the WinNT.h header file on your computer. This constant specifies that a service
is interactive in nature.
3 When a service starts, the service communicates to the Service Control Manager how long the
service must have to start (the time-out period for the service). If the Service Control Manager
does not receive a "service started" notice from the service within this time-out period, the Service
Control Manager terminates the process that hosts the service. This time-out period is typically
less than 30 seconds. If you do not adjust this time-out period, the Service Control Manager ends
the process and the attached debugger while you are trying to debug. To adjust this time-out
period, follow these steps:
a. In Registry Editor, locate, and then right-click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
b. Point to New, and then click DWORD Value. In the right pane of Registry Editor, notice that
New Value #1 (the name of a new registry entry) is selected for editing.
c. Type ServicesPipeTimeout to replace New Value #1, and then press ENTER.
d. Right-click the ServicesPipeTimeout registry entry that you created in step c, and then click
Modify. The Edit DWORD Value dialog box appears.
e. In the Value data text box, type TimeoutPeriod, and then click OK

Note TimeoutPeriod is a placeholder for the value of the time-out period (in milliseconds) that
you want to set for the service. For example, if you want to set the time-out period to 24 hours
(86400000 milliseconds), type 86400000.
f. Restart the computer. You must restart the computer for Service Control Manager to apply this
change.
4 Start your Windows service. To do this, follow these steps:
a. Click Start, and then point to Programs.
b. On the Programs menu, point to Administrative Tools, and then click Services. The Services
console appears.
c. In the right pane of the Services console, right-click ServiceName, and then click Start.

Note ServiceName is a placeholder for the name of the service that you want to debug.

COM And COM+


What are different transaction options available for services components ?
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
component in the hierarchy is transaction enabled this component will not participate in the
transaction.

Supported: - Components with transaction type supported will be a part of the transaction 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 instantiate a new transaction for
themselves every time.

Can we use com Components in .net?.How ?.can we use .net components in vb?.Explain
how ?
COM components have different internal architecture from .NET components hence they are not
innately compatible. However .NET framework supports invocation of unmanaged code from
managed code (and vice-versa) through COM/.NET interoperability. .NET application
communicates with a COM component through a managed wrapper of the component called
Runtime Callable Wrapper (RCW); it acts as managed proxy to the unmanaged COM component.
When a method call is made to COM object, it goes onto RCW and not the object itself. RCW
manages the lifetime management of the COM component. Implementation Steps -

Create Runtime Callable Wrapper out of COM component. Reference the metadata assembly Dll
in the project and use its methods & properties RCW can be created using Type Library Importer
utility or through VS.NET. Using VS.NET, add reference through COM tab to select the desired
DLL. VS.NET automatically generates metadata assembly putting the classes provided by that
component into a namespace with the same name as COM dll (XYZRCW.dll)

.NET components can be invoked by unmanaged code through COM Callable Wrapper (CCW) in
COM/.NET interop. The unmanaged code will talk to this proxy, which translates call to managed
environment. We can use COM components in .NET through COM/.NET interoperability. When
managed code calls an unmanaged component, behind the scene, .NET creates proxy called
COM Callable wrapper (CCW), which accepts commands from a COM client, and forwards it to
.NET component. There are two prerequisites to creating .NET component, to be used in
unmanaged code:
1. .NET class should be implement its functionality through interface. First define interface in
code, then have the class to imlpement it. This way, it prevents breaking of COM client, if/when
.NET component changes.

2.Secondly, .NET class, which is to be visible to COM clients must be declared public. The tools
that create the CCW only define types based
on public classes. The same rule applies to methods, properties, and events that will be used by
COM clients.

Implementation Steps -
1. Generate type library of .NET component, using TLBExporter utility. A type library is the COM
equivalent of the metadata contained within
a .NET assembly. Type libraries are generally contained in files with the extension .tlb. A type
library contains the necessary information to allow a COM client to determine which classes are
located in a particular server, as well as the methods, properties, and events supported by those
classes.
2. Secondly, use Assembly Registration tool (regasm) to create the type library and register it.
3. Lastly install .NET assembly in GAC, so it is available as shared assembly.

What is Runtime Callable wrapper?.when it will created?.


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. This wrapper turns the COM
interfaces exposed by the COM component into .NET-compatible interfaces. For oleautomation
(attribute indicates that an interface is compatible with Automation) interfaces, the RCW can be
generated automatically from a type library. For non-oleautomation interfaces, it may be
necessary to develop a custom RCW which manually maps the types exposed by the COM
interface to .NET-compatible types.

What is Com Callable wrapper?when it will created?


.NET components are accessed from COM via a COM Callable Wrapper (CCW). This is similar to
a RCW, but works in the opposite direction. Again, if the wrapper cannot be automatically
generated by the .NET development tools, or if the automatic behaviour is not desirable, a
custom CCW can be developed. Also, for COM to 'see' the .NET component, the .NET
component must be registered in the registry.CCWs also manage the object identity and object
lifetime of the managed objects they wrap.

What is a primary interop ?


A primary interop assembly is a collection of types that are deployed, versioned, and configured
as a single unit. However, unlike other managed assemblies, an interop assembly contains type
definitions (not implementation) of types that have already been defined in COM. These type
definitions allow managed applications to bind to the COM types at compile time and provide
information to the common language runtime
about how the types should be marshaled at run time.

What are tlbimp and tlbexp tools used for ?


The Type Library Exporter generates a type library that describes the types defined in a common
language runtime assembly.
The Type Library Importer converts the type definitions found within a COM type library into
equivalent definitions in a common language runtime assembly. The output of Tlbimp.exe is a
binary file (an assembly) that contains runtime metadata for the types defined within the original
type library.

What benefit do you get from using a Primary Interop Assembly (PIA)?
PIAs are important because they provide unique type identity. The PIA distinguishes the official
type definitions from counterfeit definitions provided by other interop assemblies. Having a single
type identity ensures type compatibility between applications that share the types defined in the
PIA. Because the PIA is signed by its publisher and labeled with the PrimaryInteropAssembly
attribute, it can be differentiated from other interop assemblies that define the same types.

S-ar putea să vă placă și