Friday, July 20, 2012

C#: How to Get Machine name of the webserver

Here is how you can do using C#,

Response.Write("machinename " +System.Environment.MachineName +"<BR>" )


This gives you name computer where your webserver is located.


If you need with the domain name here is how you can achieve using the following code snippet:


You need to import following namespace to use this,


using System.Net; 


public static string GetServerMachineName()
{
string domainName = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
string hostName = Dns.GetHostName();
string sysdn = "";
if (!hostName.Contains(domainName))
sysdn = hostName + "." + domainName;
else
sysdn = hostName;

return sysdn;
}

Happy Coding Smile

Wednesday, July 18, 2012

Running 32-bit Applications in 64-bit Environment

WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows. WOW64 is provided with the operating system and does not have to be explicitly enabled. For more information, see WOW64 Implementation Details.

The system isolates 32-bit applications from 64-bit applications, which includes preventing file and registry collisions. Console, GUI, and service applications are supported. The system provides interoperability across the 32/64 boundary for scenarios such as cut and paste and COM. However, 32-bit processes cannot load 64-bit DLLs for execution, and 64-bit processes cannot load 32-bit DLLs for execution. This restriction does not apply to DLLs loaded as data files or image resource files; for more information, see LoadLibraryEx.

A 32-bit application can detect whether it is running under WOW64 by calling the IsWow64Process function. The application can obtain additional information about the processor by using the GetNativeSystemInfo function.

Note that 64-bit Windows does not support running 16-bit Windows-based applications. The primary reason is that handles have 32 significant bits on 64-bit Windows. Therefore, handles cannot be truncated and passed to 16-bit applications without loss of data. Attempts to launch 16-bit applications fail with the following error: ERROR_BAD_EXE_FORMAT.

Translation libraries

The WoW64 subsystem comprises a lightweight compatibility layer that has similar interfaces on all 64-bit versions of Windows. It aims to create a 32-bit environment that provides the interfaces required to run unmodified 32-bit Windows applications on a 64-bit system. Technically, WoW64 is implemented using three dynamic-link libraries (DLLs):

  1. Wow64.dll, the core interface to the Windows NT kernel that translates between 32-bit and 64-bit calls, including pointer and call stack manipulations
  2. Wow64win.dll, which provides the appropriate entry-points for 32-bit applications
  3. Wow64cpu.dll, which takes care of switching the processor from 32-bit to 64-bit mode

Tuesday, July 03, 2012

Download: Microsoft® Visual Studio® LightSwitch™ 2011 Trial

Microsoft® Visual Studio® LightSwitch™ 2011 gives you a simpler and faster way to create professional-quality business applications for the desktop, the web, and the cloud. Using application templates, Visual Studio LightSwitch 2011 saves the time and effort of building from scratch, without sacrificing the flexibility needed to create custom applications.

Microsoft Visual Studio LightSwitch 2011 is a flexible, business application development tool that aides developers of all skill levels to quickly create and deploy desktop and web business applications. With timesaving tools and templates, and an intuitive development environment, Visual Studio LightSwitch helps speed the development and reduces the complexity of everything from UI design to Windows Azure Cloud Deployment. Now with Visual Studio LightSwitch it is finally practical to build affordable, scalable custom software solutions that bridge the gaps between existing systems and provide comprehensive, user-friendly views of your business data. For more information on Visual Studio LightSwitch 2011 visit http://www.microsoft.com/lightswitch

Download Trail

Monday, June 25, 2012

Download: Microsoft® SQL Server® 2008 R2 SP1 - Express Edition

Microsoft SQL Server 2008 R2 Express with Service Pack1 is a free, feature-rich edition of SQL Server that is ideal for learning, developing and powering desktop, web and small server applications, and for redistribution by ISVs

Download

Friday, May 18, 2012

How to: String to Pascal case from C#

We can return a string to Pascal case using regular expression or using our own logic. Here are two scenarios for doing this.

Method 1: Regular expression

public static string ToPascalCase(string pascalCaseString)
{
Regex r = new Regex("(?<=[a-z])(?<x>[A-Z])|(?<=.)(?<x>[A-Z])(?=[a-z])");
return r.Replace(pascalCaseString, " ${x}");
}


Method 2: String parsing.


/// <summary>
/// Convert the string to Pascal case.
/// </summary>
/// <param name="str">the string to turn into Pascal case</param>
/// <returns>a string formatted as Pascal case</returns>
public static string FormatPascalCase(string str)
{
StringBuilder sb = new StringBuilder(str.Length);
if (string.IsNullOrEmpty(str))
throw new ArgumentException("A null or empty value cannot be converted", str);

if (str.Length < 2)
return str.ToUpper();
// Split the string into words.
string[] words = str.Split(new char[] { }, StringSplitOptions.RemoveEmptyEntries);
foreach (string word in words)
sb.Append(string.Format("{0}{1}", word.Substring(0, 1).ToUpper(), word.Substring(1)));
return sb.ToString();
}

Hope this helps.