Thursday, July 5, 2012

.cs files got corrupted?

If your .cs file got currupted then we have one chance to recover those files.

You need to have the assembly dll related to that currupted file which was build previously.
you need to do Disassembler using .Net Reflector


Solution to recover .cs file 
1. Just Download the .Net Reflector and Install. http://www.reflector.net/
2. Open File -> ' Export Assembly source code'

3. In that Export dialogue show the dll related to corrupted file by 'Browse' option and Click 'Start'

Show any other related dll's if required while processing.


Your files will be Generated in the specified 'Output Directory' 


--Thank You

Monday, July 2, 2012

Sorting Alphanumeric


Sorting Alphanumeric:
IComparer interface
public class AlphanumComparatorFast : IComparer
{
    public int Compare(object x, object y)
    {
 string s1 = x as string;
 if (s1 == null)
 {
     return 0;
 }
 string s2 = y as string;
 if (s2 == null)
 {
     return 0;
 }

 int len1 = s1.Length;
 int len2 = s2.Length;
 int marker1 = 0;
 int marker2 = 0;
 while (marker1 < len1 && marker2 < len2)
 {
     char ch1 = s1[marker1];
     char ch2 = s2[marker2];
     char[] space1 = new char[len1];
     int loc1 = 0;
     char[] space2 = new char[len2];
     int loc2 = 0;
     do
     {
  space1[loc1++] = ch1;
  marker1++;

  if (marker1 < len1)
  {
      ch1 = s1[marker1];
  }
  else
  {
      break;
  }
     } while (char.IsDigit(ch1) == char.IsDigit(space1[0]));

     do
     {
  space2[loc2++] = ch2;
  marker2++;

  if (marker2 < len2)
  {
      ch2 = s2[marker2];
  }
  else
  {
      break;
  }
     } while (char.IsDigit(ch2) == char.IsDigit(space2[0]));

     string str1 = new string(space1);
     string str2 = new string(space2);

     int result;

     if (char.IsDigit(space1[0]) && char.IsDigit(space2[0]))
     {
  int thisNumericChunk = int.Parse(str1);
  int thatNumericChunk = int.Parse(str2);
  result = thisNumericChunk.CompareTo(thatNumericChunk);
     }
     else
     {
  result = str1.CompareTo(str2);
     }

     if (result != 0)
     {
  return result;
     }
 }
 return len1 - len2;
    }
}

//Main method
using System;
using System.Collections;

class Program
{
    static void Main()
    {
 string[] highways = new string[]
 {
     "100F",
     "50F",
     "SR100",
     "SR9"
 };
 
 Array.Sort(highways, new AlphanumComparatorFast());
 
 foreach (string h in highways)
 {
     Console.WriteLine(h);
 }
    }
}
Output:
50F
100F
SR9
SR100

How to set selectedIndex of select element using JavaScript



Example:

<input id="AnimalToFind" type="text" />
<select id="Animals">
    <option value="0">Chicken</option>
    <option value="1">Crocodile</option>
    <option value="2">Monkey</option>
</select>
<input type="button" onclick="SelectAnimal()" />
<script type="text/javascript">
    function SelectAnimal()
    {
        //Set selected option of Animals based on AnimalToFind value...
    }
 </script>
function SelectAnimal() {
    var sel = document.getElementById('Animals');
    var val = document.getElementById('AnimalToFind').value;
    for(var i = 0, j = sel.options.length; i < j; ++i) {
        if(sel.options[i].innerHTML === val) {
           sel.selectedIndex = i;
           break;
        }
    }
}

Tuesday, June 26, 2012

Error : Cannot open database requested by the login. The login failed. Login failed for user 'IIS APPPOOL\

Issue : Cannot open database  requested by the login. The login failed. Login failed for user 'IIS APPPOOL\.
This type of issues will get if u connecting to database using Windows Authentication mode you have to give permission individually if u install SQL server in Windows Authentication mode.

If u install  SQL server in window authentication by default If you do not choose mixed authentication at the time of SQL Server installation. However these modes can be changed even after installation of SQL Server.


How to Change Windows Authentication To Mixed Mode In SQL Server:
http://vijayraju-ourworld.blogspot.in/2012/06/change-windows-authentication-to-mixed.html

then restart ur Application if possible restart ur Machine then ur issue will clear

Monday, June 25, 2012

Error : How do I change the default developement environment in Visual Studio

Issue : If u selected VB or any other language as the default lDE, but now u want to change to C# or any other,
then proceed the following steps.


1. Choose Tools -> Import and Export Settings...
2. Select Reset All Settings and click Next
3. Select whether you would like to save the current settings and click Next
4. Select the settings you want to use and click Finish

Change Windows Authentication To Mixed Mode In SQL Server


When you install SQL Server by default window authentication is installed If you do not choose mixed authentication at the time of SQL Server installation. However these modes can be changed even after installation of SQL Server. 

Step 1 : Start SQL Server Management Studio
In Object Explorer Right Click In ServerName and Select Properties As Can be seen in following image.
image
Step 2 : You will Get Server Property Dialogue Box.
In Property Dialogue Box Select Security Option and under Server authentication Select “SQL Server and Window Authentication mode” and Click OK.
image
Step 3  : Enable “sa” login (Optional)
sa login is disabled by default when SQL Server is installed with window authentication. So when you choose mixed authentication you can also enable sa login (which is disabled by default).
Goto  ServerName in Object Explorer –> Security –> Logins –> Choose sa login name. Right Click on login name (sa) and click properties option see following screen shot.
image
you get following dialogue box  (login property), Under General Page. You need to set strong password and can choose option like “Enforce Password policy” making you password more secure.
image
Goto Status Page : See Following Screen Shot and Select Enable. Click Ok.  Now Re-Start SQL Server Service and login with SQL Server Authentication.
image

Note : Changing Mode From Window To Mixed Or Visa Versa Requires SQL Server Service Restart.

Sunday, June 24, 2012

Does your Visual Studio run slow?


Here are some of the good ones I found that worked.

Window > Close All Documents

Disable the customer feedback component

In some scenarios Visual Studio may try to collect anonymous statistics about your code when closing a project, even if you opted out of the customer feedback program. To stop this time-consuming behaviour, find this registry key:
?
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\{2DC9DAA9-7F2D-11d2-9BFC-00C04F9901D1}
and rename it to something invalid:
?
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\Disabled-{2DC9DAA9-7F2D-11d2-9BFC-00C04F9901D1}

Clear Visual Studio temp files

Deleting the contents of the following temp directories can fix a lot of performance issues with Visual Studio and web projects:
?
C:\Users\richardd\AppData\Local\Microsoft\WebsiteCache
C:\Users\richardd\AppData\Local\Temp\Temporary ASP.NET Files\siteName

Clear out the project MRU list

Apparently Visual Studio sometimes accesses the files in your your recent projects list at random times, e.g. when saving a file. I have no idea why it does this, but it can have a big performance hit, especially if some are on a network share that is no longer available.
To clear your recent project list out, delete any entries from the following path in the registry:
?
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList

Disable AutoRecover

In nearly four years, I have never used Visual Studio’s AutoRecover feature to recover work. These days, source control and saving regularly almost entirely eliminates the need for it.
To disable it and gain some performance (particularly with large solutions), go to Tools >Options > Environment > AutoRecover and uncheck Save AutoRecovery information. (Cheers Jake for the tip)