Posts

Showing posts from August, 2011

Replace new line (\n) or return (\r) in a document

if you want to replace unprinted characters from any text based document. you should use ^ sign before search key(s). for example : ^p : new paragraph ^l : new line ( shift + enter ) you can use it in Microsoft Office Word Find and Replace (ctrl + F) cheers... P.S:Please do not hesitate to share your comments.

calling methods asynchronous in Windows Service

Hi, if you are looking asynchronous method call to use in Windows Service .You are correct way.Asynchronous methods call is useful in windows service. First of all create delegate; public delegate void OnStartDelegate(); secondly create asynchronous call method; private void OnStartCallback(IAsyncResult ar) { ((OnStartDelegate)ar.AsyncState).EndInvoke(ar); } then use them in Start (or stop or anywhere you want) method like; OnStartDelegate OnStartDelegateInst; OnStartDelegateInst = new OnStartDelegate(OnStartAsynch); OnStartDelegateInst.BeginInvoke(OnStartCallback, OnStartDelegateInst); best wishes... P.S:Please do not hesitate to share your comments.

An Error Occured in Visual Studio about could not write to output file

Hi, if you get an error like "Could not write to output file -- 'The directory name is invalid.' " in Visual Studio 2008 while building a project, add Private Assemblies directory into Environment Variables. Directory path should be; "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;" put it into %USERPROFILE% or %TEMP% environment variables, (in case you forgot, it's here: System > Advanced > Environment Variables). regards, P.S:Please do not hesitate to share your comments.

get only date from Current Date in SQL

Hi, CONVERT(DATE,GETDATE()) cheers, P.S:Please do not hesitate to share your comments.

write Logs into Windows Event in C#

Here is the code you can use; /// /// It manages logging policy. /// use app.config of the dll to clarify debug.print logging will be used. /// default value = true /// /// caller Application Name /// Log Name /// localhost /// use additional Debug.Print Logs, every time logging occur public AdvanceLogging(string strSourceName, string strLogName, string strMachineName, bool useDebugPrint) { Microsoft.Win32.RegistryKey registrykeyLM = null; Microsoft.Win32.RegistryKey registrykeyEventlog = null; Microsoft.Win32.RegistryKey registrykeyKey = null; try { //--- Check to see that event log name exists, if so... if (System.Diagnostics.EventLog.Exists(StrLogName)) { //--- Check to see if the source exists, if not... if (!System.Diagnostics.EventLog

An Error occured while creating EventSource, The Source and Log properties must be matched, or you may set Log to the empty string

If you get " The source 'xxx SourceName' is not registered in log 'xxx LogName'. (It is registered in log 'Application'.) " The Source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the Source property. " while calling System.Diagnostics.EventLog.CreateEventSource with sourceName and LogName params,Just check registry whether SourceName is not registered in any other LogName(s). Verify LogName and SourceName in the Operationg Sytem is unique via REGEDIT; HKLM\System\CurrentControlSet\services\eventlog\ | ... if it is defined previously, you can not create . You must delete or change SourceName. regards, P.S:Please do not hesitate to share your comments.