ASp.Net day

Micro blog

Could not load file or assembly 'System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified

July 31
by Satalaj 31. July 2010 05:09


VS 2010 come up with easy way to refer the assembly from bin instead of GAC.

Could not load file or assembly 'System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified

Quick Fix

This dll System.ServiceModel.DomainServices.Hosting is a part of RIA services SDK.

You need to install it on server. Below is url to download.


http://www.microsoft.com/downloads/details.aspx?FamilyID=7b43bab5-a8ff-40ed-9c84-11abb9cda559&displaylang=en

Another way.

Before publising web, right click on assembly references and look at the properties of it.
set Copy Local to true. This will reference the assembly from bin instead of GAC.

As soon as you build your project, you will see those assemblies in bin folder copied from GAC.

If you would like to browse the GAC and copy dll manually, you can reffer below TIP.
http://www.revenmerchantservices.com/ajax/systemwebextensions.html

 

Tags:

Asp.net | Tips

MS SQL server Transaction commit rollback

April 19
by Satalaj 19. April 2010 12:21

To know your transaction is getting rolled back you need to generate an exception.

This will ensure that transcation is rolled back.

Trick is very simple, just write statement select 1/0 at the end bo transaction block as shown in below query.

select 1/0 will generate an exception and your transaction needs to be rolled back.

Begin transaction MyTransactionName

begin try

-- Delete some rows from sql server
-- insert deleted rows into other table

select 1/0  -- This will generate an exception and your transaction needs to be rolled back

commit transaction MyTransactionName

End try

begin catch

rollback transaction MyTransactionName

end catch

END

If you are using linked server, you need to enable MSDTC services (Microsoft distributed transaction co-ordinates).

Load images faster

April 17
by Satalaj 17. April 2010 12:51

 If you found that your images are getting rendered at cleint little slower, you need to consider use of httpHandler to handle the images.
so, before image getting rendered at client side you can compress it.
Also, makesure that in IIS Keep-Alive is checked or set to On. Keep-Alive ensures that client's all requests are served via single connection to serer.
requests can be anyting like page is requesting image from server or CSS from server or Java scrits from server. There would be 90% boost in loading stuff at cleint side.
If Keep-Alive is to Off, client side browser opens new connection to the server for all requests like get image, css and javascript.
Making new connection to the server is very costly. You can see this performance gain by your own.

asp.net process model

February 24
by Satalaj 24. February 2010 07:37
We can configure the Application Pool Recycling in two ways.

1. Reactive application pool process recycling.

2. Proactive application pool process recycling.

Reactive Process Recycling:
It happens when process is not functioning properly or unable to serve requests. 
Symptoms: Process deadlocks, access violations, memory leaks, Insufficiant memory and so on, in order to trigger a process recycle.
You can help control the conditions that cause a process restart by using the requestQueueLimit, memoryLimit, and shutdownTimeout configuration attributes.
For more information about these attributes, see the <processModel> Element configuration section of Machine.Config file.

Proactive Process Recycling
Proactive process recycling restarts the worker process periodically even if the process is healthy.
This can be a useful way to prevent denials of service due to conditions the process model is unable to detect.
A process can be restarted after a specific number of requests or after a time-out period has elapsed. You can enable proactive process recycling using the timeout, idleTimeout, and requestLimit configuration attributes. For more information, see the <processModel> Element configuration section of Machine.Config file.

Below are the default settings of Process model found at machine.config file.

<processModel

enable="true"

timeout="Infinite"

idleTimeout="Infinite"

shutdownTimeout="0:00:05"

requestLimit="Infinite"

requestQueueLimit="5000"

restartQueueLimit="10"

memoryLimit="60"

webGarden="false"

cpuMask="0xffffffff"

userName="machine"

password="AutoGenerate"

logLevel="Errors"

clientConnectedCheck="0:00:05"

comAuthenticationLevel="Connect"

comImpersonationLevel="Impersonate"

responseRestartDeadlockInterval="00:09:00"

responseDeadlockInterval="00:03:00"

maxWorkerThreads="20"

maxIoThreads="20"

/>


Satalaj

client server communication

January 25
by Satalaj 25. January 2010 03:47
kick it on DotNetKicks.com

  I was wondering to know how two computers can communicate with each other then I came to know its a client and server who are responsible to setup that communication.
Well, client and server both are applications or you can say computer programs.

Server: Its an application which listens on port and serves the request.

Client:  It's also an application who sends a request to server on particular port.

  Lets take an example of web, where browser (IE, FF) are clients who sends the request to server on port 80.
On server, there are multiple applications who listens on particular port, like IIS service listens on port 80 where SQL server listens on port 1433. 
First browser should know the location of server. That's nothing but the IP address of SERVER.
 Only one application can listens on port 80 it can be a IIS or Apache. Both applications can't listens on same port. That's why, if we tell the IIS to
listen on port 80 we need to tell Apache to listen on different port like 8080. So when request came to port 80, IIS will serve that request
and when request came to port 8080 Apache will serve that request.
If we are having two IP addresses assigned to the server then for IP address 192.168.1.1 we can tell the IIS to listen on port 80
and for IP address 192.168.1.2 we can tell Apache to listen on port 80. In this case requests coming to IP 192.168.1.1 port 80 will
get served by IIS and requests coming on 192.168.1.2  port 80 will get served by Apache. This is how we can resolve the conflicts.

   Lets talk about how Client communicates with server.
E.g. 
  Suppose, your IE requests a page http://www.google.com/. It will start establishing the communication with http://www.googe.com/.
During this time if you are trying to request another page of http://www.google.com/ it will establish another connection with server.
In first case, client needs to open a port with server lets say 1001 is opened to communicate with server and this port is engaged.
Means communication is not established yet. As 1001 is engaged second request opens next port 1002 with server and start communicating.
 Server establishes the communication with port 1001 and responds to client on port 1001, for second request it responds to client
on port 1002.
 You can use netstat command from command prompt to see foreign IP address , ports and local IP address, ports.
It also tell us the state of communication whether its established or waiting for server to respond.

 TCP    smartmirror:1455       bom01s01-in-f86.1e100.net:http  CLOSE_WAIT
 TCP    smartmirror:1495       digsby04.rit.edu:5222  ESTABLISHED
 TCP    smartmirror:1497       69.46.36.6:http        ESTABLISHED
 TCP    smartmirror:1501       bom01s01-in-f99.1e100.net:http  ESTABLISHE
 TCP    smartmirror:1502       bom01s01-in-f147.1e100.net:http  ESTABLISH

Here smartmirror is my local IP and 1497 is my local port who established connection with foreign IP 69.46.36.6 on port http (80)

Conclusion:
 When clients talks with server on port, it doesn't mean that clients needs to have port 80 open at his end.
Clients open the available port 1455 at his end and send requests to server on port 80. Server sends a response to client on
client side port 1455.
The detailed list of available port can be see here http://www.iana.org/assignments/port-numbers

There exists 0 to 65535 ports out of these ports, ports ranging from 49152 to 65535 are available for
dynamic or private ports.

I hope you got clear idea of how client communicates with server.

Satalaj
http://www.satalaj.com/

Tags:

Tips

HTTP Error 404 - File or directory not found.

January 19
by Satalaj 19. January 2010 05:09

  Scenario, you installed the IIS 6.0 and framework 2.0 on windows 2003 operating system. After deploying the web you observed that web is
responding an error with 404.
  By default, once you installed the IIS. It want not allow to run ASP.net or web pages or CGI, perl etc.
you need to allow them to fix this error. You need to open IIS 6.0 and find the node called Web services extensions.
In right pen you can allow or prohibit the access to ASP.net 2.0 or CGI.
For more information you can refer below link
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44f16c37-f727-4244-9813-2289e13dadba.mspx?mfr=true

or you can use support forum at www.iis.net

The default IIS settings will allow you to only see the Static pages.




Satalaj

Tags:

General | Tips

No Visual Studio template information found. See the application log in Event Viewer for more details.

January 18
by Satalaj 18. January 2010 10:20

No Visual Studio template information found.  See the application log in Event Viewer for more details.

Quick Fix:

Open .Net command promt and execute below comman

Setting environment for using Microsoft Visual Studio 2005 x64 cross tools.

c:\Program Files\Microsoft Visual Studio 8\VC>devenv /installvstemplates

c:\Program Files\Microsoft Visual Studio 8\VC>

Page view count

December 16
by Satalaj 16. December 2009 08:36

  A very common question How to count page visits to my site?
Well, it can be done in many ways. Here, I will shade some lights on simple and better approch.

Using ASp.net server side code.
 When browser begins the request, OnBeginRequest event you can count the page views againt that requet.
What if the request is coming from Load Testing tool or any robot? It is simple approch but not good.
It doesn't ensure that the request is coming from browser.

Many people think to use OnbeginRequest event. This way you will count unnecessory stuff like request to css file or javascript file or image content


Better approch:
Create a javascript which will execute at client side browser. Once it start requesting the server apply your logi to count the page visit.
This ensures that the request is coming from Browser as script engine inside the browser is making call.

You can see Google analytics and other tools who can be used to tracks the traffice on your site uses JavaScript.
If you planned to create your own, the benifit is you can have this module of tracking something out of box.

Satalaj

Tags:

Tips

iis7 32 bit mode

December 15
by Satalaj 15. December 2009 13:04
   You can't run 32bit asp.net application on IIS7 running on 64bit mode.

To run your asp.net web application on IIs7 running on 32 bit mode you need to configure you IIS 7.

First you need to open your command prompt and execute below command to configure IIS configuration.


cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64  1

Here 1 refers to true.

Then you need to run aspnet_regIIS  -i   found under framework  v2.0.

If you are still trouble shooting with IIS, post your thread at http://www.iis.net/ you can use your windows live ID to login or create new account.

 
Here are some useful stuff http://support.microsoft.com/kb/911720



Satalaj

Tags:

Tips

unable to connect to the remote server

November 09
by Satalaj 9. November 2009 12:12


 Some times our web applications or windows service or windows desktop applications throws "unable to connect to the remote server".

Make sure url or IP address is correct.

solution:
Proxy server Make sure that your not using Proxy server to access internet. If you are using proxy server to access internet,
                   contact your administrator and get the network credentials, IP address and port. Add those details in you application
                   to let it use proxy server.

Anti virus:     if you are using ESET antivirus, you need to setup rules init to allow your application in / out request on xxxx port number.

                   symantech: Disable it and then try.

Application: Application is trying to access apache server url. URL maybe case sensitve use correct url. 

                  use command prompt and execute telnet command

Telnet   ip_address   port_number

and see the response.

About Satalaj

My name is Satalaj. I'm 2010 asp.net MVP. I write technical stuff here. www.satalaj.com

Ads by Lake Quincy Media

The best inline translator

Live lookup to see what asp.net developers are searching