Monday, December 1, 2008

semaphore tell me your value

Today in morning I was little bit free from my regular work hushh..... Those sales force cases.
So I decided to write small utility which will tell me how many messages are present in the queue from another application.
Queue in this application is synchronized by using semaphore. And any point of time semaphore value Represent message count in the queue. So my thinking was if I know the name of the semaphore and required Access permission on the semaphore I can easily get the message count. But hey it is not possible to get the Current value of semaphore in .net
I found this on the forum
http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=606

An finally I have to wrap up my idea…………………………….

Saturday, August 30, 2008

Managing Security with the .NET Configuration tool

How to manage security with NET Configuration tool

1 Managing Security with the .NET Configuration tool
1.1 On the Test Machine, Start .NET Framework Configuration Tool

To run Mscorcfg.msc from the Start menu
On Windows 2000 Professional, click Start>Settings>Control Panel.>Double-click Administrative Tools.
In the Administrative Tools window, double-click Microsoft .NET Framework Configuration.
On Windows XP Professional, click Start>Control Panel>Performance and Maintenance, and click Administrative Tools.
In the Administrative Tools window, double-click Microsoft .NET Framework Configuration.
On Windows 2000 Server or Windows Server 2003 family, click Start>Programs, and point to Administrative Tools. Click Microsoft .NET Framework Configuration.
Note The command to start Mscorcfg.msc appears in the Start menu only if MMC version 1.2 or later is installed on the computer. A compatible version of MMC is included with Windows 2000 and Windows XP. If Windows 98, Windows Me, or Windows NT 4 is running on the computer, you must download and install MMC 1.2 from Microsoft.com.
To run Mscorcfg.msc from the command line
At the command line, type %Systemroot%\Microsoft.NET\Framework\versionNumber\Mscorcfg.msc
The user interface for the tool is displayed.













  • Click the Runtime Security Policy node of the console tree.

Click the Increase Assembly Trust link in the plane on the right.
The tool displays a corresponding wizard.



3. Select the option Make changes to this computer and then click the next button


4. Select the network path where the your exe is available.





5. Click the next button which will show the following window.


6. Adjust the scrollbar setting to Full trust position.
7. Click the next button.


8. Click the finish button.

Monday, August 11, 2008

India's First individual Gold Medal in Olympics



Wow !!! Abhinav Bindra of India has won India its first Gold medal for 10 Meter Air Rifle.what a great moment for India .
This is the first individual Gold medal for India in Olympics. Abhinav you make us proud .
He score of (596+140.5) 700.5
In ten rounds, Bindra shot 10.7, 10.3, 10.4, 10.5, 10.5, 10.5, 10.6, 10.0, 10.2, 10.8 to clinch the first berth. China's Qinan Zhu won silver while Finland's Henri Hakkinen won bronze.

Sunday, July 20, 2008

How to detect browser close event in IE7

How to detect browser close event
I have written a code to detect the bowser close event in IE6 which looks like






This works well with IE6. Unfortunately, IE7 browser returns positive clientX value even if mouse pointer is out of client area.This means that the trick which I used in IE6 case will not work on IE7.



I searched solution for this problem on net but I didn't find any perfect solution.
So I tried myself to find out the solution. In the below sample code I tried to go closer to the solution of problem and tried to cover maximum number of condition such as atr+X ,Popup window ,mouse click on close button etc.

There is no “universal way” to determine if the browser has been closed. You can only determine if a browser window (web page) has been closed or navigated away from, provided you understand that the events illustrated below are generated not only when a user triggers the closing of a window, but the same events fire on a “refresh” too. So this fact probably defeats your purpose. Using the methodologies described, you can’t tell if the user clicked the “Red X” or the “Refresh” button, let alone the browser’s top right “X” or “File->Exit” menu item.

Note:Please replace "replace" keyword in the below code with "script"keyword .




<[[CDATA[


var alterffourflag=0;
var lastkey=0;
var refreshflag=0;
document.onkeydown = function ( event )
{
event = event window.event;
return window_onkeydown();
}


ie7=navigator.userAgent.toLowerCase().indexOf('msie 7')!=-1;
if(ie7==1)
{
if(window.document.referrer.toString()=="")//to detect popup window in the IE7
{
return;
}
var offset=0.0;
var width=0.0;
if( document.documentElement && ( document.documentElement.clientWidth ))
{
//IE 6+ in 'standards compliant mode'
width = document.documentElement.clientWidth;
}
else if( document.body && ( document.body.offsetWidth))
{
width=document.body.offsetWidth;
}
offset=18500/screen.width;
var diff =width-offset;
if (refreshflag!=1 && width!=0 && window.event.clientY <> (width - offset))alterffourflag==1)
{
if( window.opener == null)
{
if (window.XMLHttpRequest)
{
req=new XMLHttpRequest();
req.open("GET", "../ping.aspx" + "?t=" + new Date(), false);//page which removes session information
req.send(null);
}
else
{
if (window.ActiveXObject)
{
req = new ActiveXObject("Microsoft.XMLHTTP");
req.open("GET", "../ping.aspx" + "?t=" + new Date(), false);
req.send(null);
}
}
}
}
refreshflag=0;
}
else// IE6
{
if (self.screenTop > 10000 && event.clientY < opener ="=" req="new" t=" + new Date(), false); req.send(null); } else { if (window.ActiveXObject) { req = new ActiveXObject(" t="">

function window_onkeydown()
{
var keynum
var numcheck
e=window.event;
keynum = e.keyCode;
if(lastkey==18 && keynum==115)//(lastkey==17 && keynum==87))
{
alterffourflag=1;
}
if(keynum==116)
{
refreshflag=1;
}
lastkey=keynum;
}

]]>

Wednesday, July 9, 2008

Problem while loading the Assembly In web application

Yesterday I came across a below problem in my web application. After lots of search on google I couldn't figure out the reason .After some investigation I found that this problem appeared after machine poweroff because of power cut .

After reinstalling my .net framework version below problem get resolved .


Could not load file or assembly 'myinterface or one of its dependecies .The Parameter is incorrect (Exception From HRresult : 0x80070057(E_INVALIDARG))

Could not load file or assembly 'myinterface, Version=4.0.0.9185, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileLoadException: Could not load file or assembly 'myinterface, Version=4.0.0.9185, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Assembly Load Trace: The following information can be helpful to determine why the assembly 'myinterface, Version=4.0.0.9185, Culture=neutral, PublicKeyToken=null' could not be loaded.WRN: Assembly binding logging is turned OFF.To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.Note: There is some performance penalty associated with assembly bind failure logging.To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].Stack Trace: [FileLoadException: Could not load file or assembly 'myinterface, Version=4.0.0.9185, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.] mYWebsite..LOGINPage_Load(Object sender, EventArgs e) +0 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061--------------------------------------------------------------------------------Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42 --------------------------------------------------