Techaray

Shailendra Saxena's Technical Blog

Windows Communication Foundation Built-In Bindings

clock January 31, 2013 05:44 by author ShailendraSaxena

 

Binding Class Name

Transport

Message Encoding

Message Version

Security Mode

Reliable Messaging

Transaction Flow (disabled by default)

BasicHttpBinding

HTTP

Text

SOAP 1.1

None

Not Supported

Not Supported

WSHttpBinding

HTTP

Text

SOAP 1.2 WS-Addressing 1.0

Message

Disabled

WS-AtomicTransactions

WSDualHttpBinding

HTTP

Text

SOAP 1.2 WS-Addressing 1.0

Message

Enabled

WS-AtomicTransactions

WSFederationHttpBinding

HTTP

Text

SOAP 1.2 WS-Addressing 1.0

Message

Disabled

WS-AtomicTransactions

NetTcpBinding

TCP

Binary

SOAP 1.2

Transport

Disabled

OleTransactions

NetPeerTcpBinding

P2P

Binary

SOAP 1.2

Transport

Not Supported

Not Supported

NetNamedPipesBinding

Named Pipes

Binary

SOAP 1.2

Transport

Not Supported

OleTransactions

NetMsmqBinding

MSMQ

Binary

SOAP 1.2

Message

Not Supported

Not Supported

MsmqIntegrationBinding

MSMQ

Not Supported (uses a pre-WCF serialization format)

Not Supported

Transport

Not Supported

Not Supported

CustomBinding

You Decide

You Decide

You Decide

You Decide

You Decide

You Decide



What is a Partial Classes

clock January 30, 2013 18:02 by author ShailendraSaxena

Partial Classes

 

A class can contain a number of methods, fields, and constructors. A highly functional class can become quite large. With C#, you can split the source code for a class into separate files so that you can organize the definition of a large class into smaller, easier to manage pieces. This feature is used by Microsoft Visual Studio 2010 for Windows Presentation Foundation (WPF) applications, where the source code that the developer can edit is maintained in a separate file from the code that is generated by Visual Studio whenever the layout of a form changes.

When you split a class across multiple files, you define the parts of the class by using the partial keyword in each file. For example, if the Circle class is split between two files called circ1.cs (containing the constructors) and circ2.cs (containing the methods and fields), the contents of circ1.cs look like this:

 

partial class Circle

{

public Circle() // default constructor

{

this.radius = 0;

}

public Circle(int initialRadius) // overloaded constructor

{

this.radius = initialRadius;

}

}

 

The contents of circ2.cs look like this:

 

partial class Circle

{

private int radius;

public double Area()

{

return Math.PI * this.radius * this.radius;

}

}

 

When you compile a class that has been split into separate files, you must provide all

the files to the compiler.

There are several rules to follow when working with partial class definitions:

·         All partial-type definitions meant to be parts of the same type must be modified with partial. For example, the following class declarations generate an error:

publicpartialclass A { }
//public class A { }  // Error, must also be marked partial
 

·         The partial modifier can only appear immediately before the keywords class, struct, or interface.

·         Nested partial types are allowed in partial-type definitions, for example:

partialclass ClassWithNestedClass
{
    partialclass NestedClass { }
}
 
partialclass ClassWithNestedClass
{
    partialclass NestedClass { }
}

·         All partial-type definitions meant to be parts of the same type must be defined in the same assembly and the same module (.exe or .dll file). Partial definitions cannot span multiple modules.

·         The class name and generic-type parameters must match on all partial-type definitions. Generic types can be partial. Each partial declaration must use the same parameter names in the same order.

·         The following keywords on a partial-type definition are optional, but if present on one partial-type definition, cannot conflict with the keywords specified on another partial definition for the same type:

o    public

o    private

o    protected

o    internal

o    abstract

o    sealed

o    base class

o    new modifier (nested parts)

o    generic constraints (For more information, see Constraints on Type Parameters (C# Programming Guide).)

Example 1

In the following example, the fields and the constructor of the class, “CoOrds”, are declared in one partial class definition, while the member, “PrintCoOrds”, is declared in another partial class definition.

publicpartialclass CoOrds
{
    privateint x;
    privateint y;
 
    public CoOrds(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
}
 
publicpartialclass CoOrds
{
    publicvoid PrintCoOrds()
    {
        System.Console.WriteLine("CoOrds: {0},{1}", x, y);
    }
 
}
 
class TestCoOrds
{
    staticvoid Main()
    {
        CoOrds myCoOrds = new CoOrds(10, 15);
        myCoOrds.PrintCoOrds();
    }
}
 

Output

CoOrds: 10,15

Example 2

The following example shows that you can also develop partial structs and interfaces.

partialinterface ITest
{
    void Interface_Test();
}
 
partialinterface ITest
{
    void Interface_Test2();
}
 
partialstruct S1
{
    void Struct_Test() { }
}
 
partialstruct S1
{
    void Struct_Test2() { }
}


Generations in Garbage Collections

clock January 30, 2013 07:43 by author ShailendraSaxena

 

The heap is organized into generations so it can handle long-lived and short-lived objects. Garbage collection primarily occurs with the reclamation of short-lived objects that typically occupy only a small part of the heap. There are three generations of objects on the heap:

·         Generation 0. This is the youngest generation and contains short-lived objects. An example of a short-lived object is a temporary variable. Garbage collection occurs most frequently in this generation.

Newly allocated objects form a new generation of objects and are implicitly generation 0 collections, unless they are large objects, in which case they go on the large object heap in a generation 2 collections.

Most objects are reclaimed for garbage collection in generation 0 and do not survive to the next generation.

·         Generation 1. This generation contains short-lived objects and serves as a buffer between short-lived objects and long-lived objects.

·         Generation 2. This generation contains long-lived objects. An example of a long-lived object is an object in a server application that contains static data that is live for the duration of the process.

Garbage collections occur on specific generations as conditions warrant. Collecting a generation means collecting objects in that generation and all its younger generations. A generation 2 garbage collection is also known as a full garbage collection, because it reclaims all objects in all generations (that is, all objects in the managed heap).



Useful Links

clock January 30, 2013 07:08 by author ShailendraSaxena
Useful Links
C# Programming Guide http://msdn.microsoft.com/en-us/library/67ef8sbd%28v=vs.100%29.aspx
Extension Methods http://msdn.microsoft.com/en-us/library/bb383977%28v=vs.100%29.aspx
Lambda Expressions http://msdn.microsoft.com/en-us/library/bb397687%28v=vs.100%29.aspx
   
   
   
   
   
   
   
   


' ' is not declared. It may be inaccessible due to its protection level.

clock January 25, 2013 04:55 by author ShailendraSaxena

 

 

BackGround

I receive the error ‘ ’ is not declared. It may be inaccessible due to its protection level.While building the solution.

Resolution

I changed the from ".NET Framework 3.5" to ".NET Framework 4" as below.

 

 



Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

clock January 25, 2013 04:52 by author ShailendraSaxena

 

BackGround :

I had an application which was using .net framework version 2.0 then I added some dll of version 4.o then all of sudden when running the application I got the above error.

 

Resolution:

I add the below code in my all app.config of projects of my solution.

<startupuseLegacyV2RuntimeActivationPolicy="true">

      <supportedRuntimeversion="v4.0"/>

    </startup>

 



Microsoft JScript runtime error: 'Sys' is undefined

clock January 8, 2013 09:59 by author ShailendraSaxena

ASP.NET Ajax framework failed to load client side framework

 I face below errors at a same time.

ASP.Net Ajax framework failed to load client side framework
Microsoft JScript runtime error: 'Sys' is undefined
and Telerik is undefined.
 
If somebody else also got this error, below is what i did to resolve this error.
I had below in my web.config 
 
<add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd"
                 type="Telerik.Web.UI.WebResource" verb="*"
                 preCondition="integratedMode,runtimeVersionv2.0"/>  
 
 
I removed runtimeversion2.0 and it worked well.
 
Just to update you that it was working well in IIS6.0 but error occured when i deploy it on IIS7.0
 
So the above entry was in <system.webServer> tag, which is basically for iis7 specific.
 
It took my lot of time to resolve this issue.


Access Modifiers in C#

clock January 6, 2013 23:25 by author ShailendraSaxena

 

Declared accessibility

Meaning

public

Access is not restricted.

protected

Access is limited to the containing class or types derived from the containing class.

internal

Access is limited to the current assembly.

protected internal

Access is limited to the current assembly or types derived from the containing class.

private

Access is limited to the containing type.



Search

Calendar

<<  June 2017  >>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

Archive

Tags

Categories


Visitors

FlagCounter

Flag Counter

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017

Sign In