Posts

Showing posts from 2011

Learn how to develop for Android, Beyond HelloWorld

Learn how to develop for Android, Beyond HelloWorld

How to convert the character array to String

char[] english = { 'E', 'N', 'G', 'L', 'I', 'S', 'H' }; string strEnglish = new string(english); Console.WriteLine(english); Console.ReadLine();

How to pass parameters to the function called by ElapsedEventHandler?

http://stackoverflow.com/questions/3094422/how-to-pass-parameters-to-the-function-called-by-elapsedeventhandler private static void InitTimer ( int Index ) { keepAlive [ Index ] = new Timer (); keepAlive [ Index ]. Interval = 3000 ; keepAlive [ Index ]. Elapsed += ( sender , args ) => KeepAliveElapsed ( sender , Index ); keepAlive [ Index ]. Start (); } public static void KeepAliveElapsed ( object sender , int Index ) { PacketWriter writer = new PacketWriter (); writer . AppendString ( "KEEPALIVE|.\\" + sender ); ServerSocket . Send ( writer . getWorkspace (), Index ); ServerSocket . DisconnectSocket ( Index ); }

"Unrecoverable build error" on any MSI Setup project

If you get an error while building MSI project in your VDI machine please follow the below steps. 1. Close down Visual Studio. 2. Start, Run or WIN+R, type cmd, OK. 3. regsvr32 "C:\Program Files\Common Files\Microsoft Shared\MSI Tools\mergemod.dll" 4. regsvr32 ole32.dll 5. Close Command Prompt. 6. Open up Visual Studio and try rebuilding your deployment project!

How To Split A Comma Delimited String

In one of my previous posts I wrote about “ How to Create a Comma Delimited List ”. Now I’ll show you an example with reverse action, that is Splitting a Comma Delimited String or array() of values. There can be different types of Delimiters also : like Comma ' , ', vertical bar ' | ', Single space or a Tab. For example here is our Sample Table - Id AllNames 1 A,B,C 2 A,B 3 X,Y,Z And here is the expected output - Id Names 1 A 1 B 1 C 2 A 2 B 3 X 3 Y 3 Z Create Sample Data : -- Create Table for Sample Data CREATE TABLE Test ( ID INT , AllNames VARCHAR (100...

Regular Expression For UNICODE Characters

char c = 'Ú' ; // 'Ÿ'; Console .WriteLine( "{0} U+{1:x4} {2}" , c, ( int )c, ( int )c); char MyChar = '\u0058' ; string x= Convert .ToString(MyChar); Regex reg = new Regex ( @"^[-0-9a-zA-Z\&\+\{\}\.\>\u0178\u00da''-'\s]{246}$" ); if (reg.IsMatch(sample)) Console .WriteLine( "matched" ); else Console .WriteLine( "UnMatched" );

Attach Windows Service Process

Install the window service, start the service in Services.msc To Attch the process, Debug ->Attch Process If does not list, Close and open the visual studio Restart the System.

windows-service-setup-project-run-service-as-administrator

You should be able to add a new ServiceProcessInstaller in the InitializeComponent() method of your installer. This class will allow you to set account type, username, and password that you want the service to run as. For example: this.Installers.Add( new System.ServiceProcess.ServiceProcessInstaller() { Account = ServiceAccount.User, Username = @"domain\username", Password = "password" }); If you don't want to hardcode a password into your setup project, then leave it blank and a popup dialog should appear asking for this during install. http://stackoverflow.com/questions/1692679/windows-service-setup-project-run-service-as-administrator

How to Install Windows Service

Creating the solution To create the solution, use "File." "New." and select "Blank Solution. from the Visual Studio development environment. For this example, call the solution "ServiceSolution". All related projects (especially those that will be part of a installation, should become a project within the root solution. This keeps all inter-project dependencies relative to one another an simplifies the process if another developer decides to use a working folder. The next step is to create two new projects as part of this solution the service application and the installation package. Right click on the solution within the Solution Explorer and select "Add." and the "New Project." from the Visual C# projects folder, choose "Window Service". Name the project "TestService". The resulting project should now be in design mode and ready to add the installation components. The C# source file "Service1" and th...

XML Select Single Node

Ref http://msdn.microsoft.com/en-us/library/h0hw012b.aspx <pre> <bookstore xmlns="http://www.lucernepublishing.com"> <book> <title>Pride And Prejudice</title> </book> </bookstore> </pre> XmlDocument doc = new XmlDocument(); doc.Load( "booksort.xml" ); //Create an XmlNamespaceManager for resolving namespaces. XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace( "bk" , "urn:samples" ); //Select the book node with the matching attribute value. XmlNode book; XmlElement root = doc.DocumentElement; book = root.SelectSingleNode( "descendant::book[@bk:ISBN='1-861001-57-6']" , nsmgr); Console.WriteLine(book.OuterXml);