Documente Academic
Documente Profesional
Documente Cultură
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 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.
How can you automatically generate interface for the remotable object in .NET with Microsoft tools?
Use the Soapsuds tool.
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.
True or False: To test a Web service you must create a windows application or Web
application to consume this service?
False.
2.Synchronous Call
Application has to wait until execution has completed.
<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>
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.
<%
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.
[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
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
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.
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 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.