cSharpTechie
.Net Rider is running by IT professionals for sharing issues/Solutions for .Net developers.
Saturday, May 6, 2023
Docker basics
Installation.
Go to https://docs.docker.com/engine/install/
We can go with Docker Window installations
https://docs.docker.com/desktop/install/windows-install/
PC should have
WSL 2 backend
or
Hyper-V backend and Windows containers
Docker Desktop uses the Windows Hyper-V features. While older Windows versions have Hyper-V, their Hyper-V implementations lack features critical for Docker Desktop to work.so Windows 10 or Windows 11 required
Monday, November 11, 2013
What is Backward compatibility in .Net
What
is Backward compatibility
http://bytes.com/topic/asp-net/insights/952841-what-backward-compatibility-net
Backward compatibility means that an app that was developed for a
particular version of a platform will run on later versions of that platform.
The .NET Framework tries to maximize backward compatibility: Source code
written for one version of the .NET Framework should compile on later versions
of the .NET Framework, and binaries that run on one version of the .NET
Framework should behave identically on later versions of the .NET Framework
The .NET Framework 4.5 and its point releases are backward-compatible with
apps that were built with earlier versions of the .NET Framework. In other
words, apps and components built with previous versions will work without
modification on the .NET Framework 4.5. However, by default, apps run on the
version of the common language runtime for which they were developed, so you
may have to provide a configuration file to enable your app to run on the .NET
Framework 4.5. For more information
ü Note
that the .NET Framework 4.5 is not supported on Windows XP.
ü .net
4.5 comes automatically with windows 8
ü .net
3.5 sp1 comes automatically with windows 7 sp1
http://bytes.com/topic/asp-net/insights/952841-what-backward-compatibility-net
Relationship between CLR and .Net framework version
It depends upon CLR for .net framework we are using.
a) NET Framework 2.0, 3.0, and 3.5 include CLR 2.0.
b) .NET Framework 4, 4.5, and 4.5.1 include CLR 4.0
c) CLR 3.0 does not exist
d) Application developed in 2.0,3.0 can run in 3.5 framework because target CLR is same
but application developed in 3.0 will not run on 4.5 framework because now target framework is different (CLR4)
NET Framework 1.0: "v1.0.3705"
o .NET Framework 1.1: "v1.1.4322"
o .NET Framework 2.0, 3.0, and 3.5: "v2.0.50727"
o .NET Framework 4 and 4.5 (including point releases such as 4.5.1): "v4.0
http://bytes.com/topic/asp-net/insights/952842-relation-ship-between-clr-net-framework-version
a) NET Framework 2.0, 3.0, and 3.5 include CLR 2.0.
b) .NET Framework 4, 4.5, and 4.5.1 include CLR 4.0
c) CLR 3.0 does not exist
d) Application developed in 2.0,3.0 can run in 3.5 framework because target CLR is same
but application developed in 3.0 will not run on 4.5 framework because now target framework is different (CLR4)
NET Framework 1.0: "v1.0.3705"
o .NET Framework 1.1: "v1.1.4322"
o .NET Framework 2.0, 3.0, and 3.5: "v2.0.50727"
o .NET Framework 4 and 4.5 (including point releases such as 4.5.1): "v4.0
http://bytes.com/topic/asp-net/insights/952842-relation-ship-between-clr-net-framework-version
Array support more than two gigabyte size in .Net 4.5
Problem Statement
Sometimes with 64-bit support on the .NET Framework is the limitation on arrays, which cannot exceed 2 GB. One of the main reasons you move to 64-bit platforms is to access more than 2 GB, and this limitation was a big problem for those of us trying to work with large matrices and vectors. No matter the amount of available RAM available, it was very common to have a System.OutOfMemoryException
Solution
.NET Framework 4.5 introduces a configuration attribute in the run-time schema that enables arrays larger than 2 GB in total size on 64-bit applications. You need only enable the gcAllowVeryLargeObjects element that controls the behavior of the .NET garbage-collection system.
<configuration>
< startup>
< supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
< /startup>
< runtime>
< gcAllowVeryLargeObjects enabled="true" />
< /runtime>
< /configuration>
http://bytes.com/topic/net/insights/952845-array-support-more-than-two-gigabyte-size-net-4-5-a#post3760563
Sometimes with 64-bit support on the .NET Framework is the limitation on arrays, which cannot exceed 2 GB. One of the main reasons you move to 64-bit platforms is to access more than 2 GB, and this limitation was a big problem for those of us trying to work with large matrices and vectors. No matter the amount of available RAM available, it was very common to have a System.OutOfMemoryException
Solution
.NET Framework 4.5 introduces a configuration attribute in the run-time schema that enables arrays larger than 2 GB in total size on 64-bit applications. You need only enable the gcAllowVeryLargeObjects element that controls the behavior of the .NET garbage-collection system.
<configuration>
< startup>
< supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
< /startup>
< runtime>
< gcAllowVeryLargeObjects enabled="true" />
< /runtime>
< /configuration>
http://bytes.com/topic/net/insights/952845-array-support-more-than-two-gigabyte-size-net-4-5-a#post3760563
Session_End event does not fire in OutProc session mode
Session_End is Fired when a user's session times out.
When Webserver did not get any response for 20 min by default then Session_end automatically fires.
Another important thing to write this topic here is that, Session_end only fires incase of Inproc session mode, not for Outproc session mode.
We can use Session.Abandon to force this.
Remember the Session_End event will not fire in case the user closes the browser. HTTP is a stateless protocol. There is no way for the server to understand that the browser has been closed.
Happy Coding !!!!!!!!!!!!!!!
When Webserver did not get any response for 20 min by default then Session_end automatically fires.
Another important thing to write this topic here is that, Session_end only fires incase of Inproc session mode, not for Outproc session mode.
We can use Session.Abandon to force this.
Remember the Session_End event will not fire in case the user closes the browser. HTTP is a stateless protocol. There is no way for the server to understand that the browser has been closed.
Happy Coding !!!!!!!!!!!!!!!
Sunday, November 10, 2013
Session_end for InProc and OutProc session mode in Asp.net
Session_End is Fired when a user's session times out.
When Webserver did not get any response for 20 min by default then Session_end automatically fires.
We can use Session.Abandon to force this.
Another important thing to write this topic here is that, Session_end only fires incase of Inproc session mode, not for Outproc session mode.
Remember the Session_End event will not fire in case the user closes the browser. HTTP is a stateless protocol. There is no way for the server to understand that the browser has been closed.
Happy Coding !!!!!!!!!!!!!!!
When Webserver did not get any response for 20 min by default then Session_end automatically fires.
We can use Session.Abandon to force this.
Another important thing to write this topic here is that, Session_end only fires incase of Inproc session mode, not for Outproc session mode.
Remember the Session_End event will not fire in case the user closes the browser. HTTP is a stateless protocol. There is no way for the server to understand that the browser has been closed.
Happy Coding !!!!!!!!!!!!!!!
Friday, November 8, 2013
Garbage Collection Improvement in .Net 4.5
Problem statement
Garbage
collector is one real heavy task in a .NET application. And it becomes heavier
when it is an ASP.NET application. ASP.NET applications run on the server and a
lot of clients send requests to the server thus creating loads of objects,
making the GC really work hard for cleaning up unwanted objects.
Solution
Concurrent garbage collection
To overcome the above problem, server GC was introduced. In
server GC there is one more thread created which runs in the background. This
thread works in the background and keeps cleaning. objects thus minimizing the
load on the main GC thread. Due to double GC threads running, the main
application threads are less suspended, thus increasing application throughput.
To enable server GC, following to do
<configuration>
<runtime><gcServer enabled="true"/>
</runtime>
</configuration>
Profile optimization (Improved startup performance) in .Net 4.5
This is also known as Multicore JIT
Problem
When the application is run, the IL code is read by the CLR and JIT compiled into native code for the particular machine
So the compilation from the IL Code to the native code happens when the application is actually running. So application generally takes lot of time at start up.
Problem
When the application is run, the IL code is read by the CLR and JIT compiled into native code for the particular machine
So the compilation from the IL Code to the native code happens when the application is actually running. So application generally takes lot of time at start up.
Profile optimization is improvement
over start up time.
Profile optimization
·
The fundamental problem with JIT compilation is
, Jitting is normally a lazy operation, it Jits a method and do not know what
next method is for jitting. So the solution is it has to remember something
from previous run which is
all the jitting that happened
·
.net framework 4.5 supports this optimization
using application profiles. Now we can enable the profile optimization for an
application. Based on the historic profile, it keeps JIT compiling the methods
in the background. So when the code is actually needed for execution, it is
already in native format so the runtime doesn't have to wait for this.
·
Profile is nothing but a simple file which has a
list of methods which the application will need during startup
·
Multicore JIT parallelizes the some of the JIT
compilations that happens on the start of the application
Profile optimization requires a multicore
computer. The methods are ignored on other computers
Async and await in .Net 4.5
Before moving ahead I want to introduce basic concept
of Asynchronous Programming
Problem
Sometimes in our
web application we request for data from webserver and we have to wait for
response. So in this case our entire application is blocked and user have to
wait till response from webserver.
Solution
Asynchronous
Programming is introduced to overcome above problem.
Asynchrony is
essential for activities that are potentially blocking, such as when your
application accesses the web. Access to a web resource sometimes is slow or
delayed. If such an activity is blocked within a synchronous process, the
entire application must wait. In an asynchronous process, the application can
continue with other work that doesn't depend on the web resource until the
potentially blocking task finishes
Difference between synchronous/asynchronous
operations
a)
Synchronization
means two or more operations are running in a same context (thread) so that one
may block another
b)
Synchronization
means two or more operations happen sequentially.
c)
Asynchronous
means two or more operations are running in different contexts (thread) so that
they can run concurrently and do not block each other.
Synchronous operation (fig 1)
|
Asynchronous operation (fig 2)
|
|
|
|
Explanation
1) From fig 1
a. Each task occurs in sequence.
b. Here from fig, step3 have to wait to
complete step2
2)
From
fig2
a.
async and await keywords has been introduced
b.
async
and await are pair keywords. You cannot use them in a standalone manner.
c.
async
is marked on a method. This keyword is just an indicator saying that this
method will have the await keyword.
d.
The
await keyword marks the position from where the task should resume. So you will
always find this keyword in conjunction with Task.
Here Step3 will execute
without waiting for step2 to complete
Subscribe to:
Posts (Atom)

