.Net Interview Questions @dotnetiq2 Channel on Telegram

.Net Interview Questions

@dotnetiq2


.Net Interview Questions

.Net Interview Questions (English)

Are you looking to land your dream job in the world of .Net development? Look no further! Introducing the '.Net Interview Questions' Telegram channel, designed to help you ace your next interview with confidence. Who is it? This channel is perfect for aspiring .Net developers, seasoned professionals looking to brush up on their skills, or anyone interested in diving deeper into the world of .Net development. Whether you're a beginner or an expert, there's something here for everyone. What is it? The '.Net Interview Questions' Telegram channel is a treasure trove of valuable resources, including a wide range of interview questions, tips, and tricks to help you succeed in your next .Net interview. Stay updated on the latest trends, best practices, and industry insights related to .Net development. With daily updates and interactive discussions, you can expect to sharpen your skills, expand your knowledge, and boost your confidence when facing those tough interview questions. Join a community of like-minded individuals who are passionate about .Net development and are committed to helping each other succeed. Don't miss out on this valuable opportunity to take your .Net skills to the next level. Join the '.Net Interview Questions' Telegram channel today and unlock your full potential in the world of .Net development. Happy coding!

.Net Interview Questions

17 Dec, 13:19


WS-Policy is generally used for
1. Describing protocols for accessing operations
2. Security
3. Reliable messaging
4. Transactions
5. Message encoding (Message Transmission Optimization Mechanism [MTOM])
6. Other protocols
You can specify the above settings in WSDL directly without a policy section, but the disadvantage is that, once published, the WSDL contract is final. If the clients has to communicate with a WCF service that has changed the settings in the WSDL, the clients need to rebuild the proxy and configuration or atleast the changes to the WSDL contract must support backward compatibility.

The advantage of using WS-Policy is that it can change over time, and the clients can discover the changed policy to communicate via metadata exchange. But keep in mind that, you can only change the policy safely if clients are positioned to handle dynamic changes

.Net Interview Questions

17 Dec, 13:19


🚩2⃣6⃣9⃣ What is the use of WS-Policy?

.Net Interview Questions

17 Dec, 13:16


There are several advantages of using MessageContract attribute in WCF. MessageContract attribute can be used for
1. Adding custom headers to the message.
2. Controling message wrapping.
3. Controling signing and encryption of messages.

.Net Interview Questions

17 Dec, 13:16


🚩2⃣6⃣8⃣ Explain the significane of MessageContract attribute? OR Why and when do you use MessageContract attribute?

.Net Interview Questions

17 Dec, 13:15


The best way to serialize Polymorphic Types in WCF is to use KnownType attribute on the parent type as shown in the example below. CorporateCustomer and PremiumCustomer classes inherit from Customer class,and hence we can associate CorporateCustomer and PremiumCustomer types as known types in 3 different ways depending on the project requirement.

1. Associate known types to the base types themselves.
2. Associate known types to particular operations.
3. Associate known types to the service contract as a whole.

.Net Interview Questions

17 Dec, 13:14


🚩2⃣6⃣7⃣ What is the best way to serialize Polymorphic Types in WCF?

.Net Interview Questions

07 Mar, 10:57


The preferred way for serializing complex types in WCF is to use data contracts. Using Data Contracts provides us with the following advantages.
1. Using DataMember attribute, you can control which members of the class to serialize.
2. You can also control the order in which members are serialized using Order parameter of the DataMember attribute..
3. You can also provide explicit Name to the serialized members using Name parameter of the DataMember attribute.
4. You can also specify if a member is required or optional using IsRequired parameter of the DataMember attribute.
Consider the example below which uses Name, IsRequired and Order parameters of the DataMember attribute to serialize CustomerId property. By the way DataMember attribute can be used with either fields or properties. If you donot specify the order in which members are serialized, then by default alphabetical ordering is done by the DataContractSerializer.

.Net Interview Questions

07 Mar, 10:57


🚩2️⃣6️⃣6️⃣ What is the preferred way for serializing complex types in WCF?

.Net Interview Questions

07 Mar, 10:56


When we decorate a class with Serializable attribute, all the fields of the class are serialized regardless of the accessibility. We donot have control on what to serialize and what not to serialize. We also will not have any control over naming conventions or data types.

.Net Interview Questions

07 Mar, 10:56


🚩2️⃣6️⃣5️⃣ What is the disadvantage of using Serializable attribute to serialize a complex type that is sent and received between clients and services in WCF?

.Net Interview Questions

07 Mar, 10:56


The following are the different options available to serialize complex types that are exchanged between clients and services in WCF. These options have their own advantages and disadvanatages. Data contracts is thepreferred way to serialize complex types in WCF.
1. Serializable types - Us the Serializable attribute on the type that you want to serialize
2. Data contracts - Use DataContract attribute on the type and DataMember attribute on every member of the type, that you want to serialize. You can apply DataMember attribute either on a filed or a property.
3. Known types - Use Known types to enable polymorphic behavior in service contracts.
4. IXmlSerializable - IXmlSerializable types provide XSD schema to Web Services Description Language (WSDL) and metadata exchange (MEX).

.Net Interview Questions

07 Mar, 10:55


🚩2️⃣6️⃣4️⃣ What are the different options available to serialize complex types that are sent and received between clients and services in WCF?

.Net Interview Questions

07 Mar, 10:55


Normally, by default, when some exception occurs at a WCF service level, it will not be exposed as it is to the client. The reason is that the WCF exception is a CLR exception and it doesn't make sense to expose it outside of the CLR because it contains internal details of service code like stack trace. So, WCF handles and returns error details to the client using a Fault Contract.
So, a fault contract is a contract that contains the details of possible exception(s) that might occur in service code

.Net Interview Questions

07 Mar, 10:55


🚩2️⃣6️⃣3️⃣ What is a fault contract?

.Net Interview Questions

07 Mar, 10:53


MessageParameter attribute is used to control the parameter and returned object names from a service operation. Consider the example below. On the service side, the method parameter name in SaveCustomer([MessageParameter(Name = "Customer")] Customer cust) is cust. If we donot use MessageParameter attribute, then "cust" is what is exposed as parameter name to the client, which is not very proffesional. So we are using MessageParameter attribute to expose the method parameter name as Cutomer.

.Net Interview Questions

07 Mar, 10:53


🚩2️⃣6️⃣2️⃣ What is the purpose of MessageParameter attribute in WCF?

.Net Interview Questions

07 Mar, 10:53


Yes, a ServiceContract attribute can be applied either to a class or an interface, but defining service contracts using interfaces rather classes has the following benifits.

1. Defining service contracts using interfaces, removes coupling to service implementation. Later the implementation can be changed at will without affecting the clients.
2. Defining service contracts using interfaces, also allows a service to implement more than 1 contract.

.Net Interview Questions

07 Mar, 10:52


🚩2️⃣6️⃣1️⃣ Can you apply service contract attribute to a class rather than an interface in WCF?

.Net Interview Questions

07 Mar, 10:51


2. Operation Contract - All methods in a service contract should
have OperationContract attribute. You can also provide explicit Name, Action
and ReplyAction as shown in the example below.

.Net Interview Questions

07 Mar, 10:51


1. Service Contract - An interface that exposes the service operations is usually decorated with the service contract attribute. Always provide meaningful Namespace and Name to a service contract as shown in theexample below.