If a service has been uninstantiated from services.msc than it first needs to close services.msc window before installing it again.
Most peoples have been observed restarting system to fix this and as it is a common situation for services development, hopefully this post will save a few reboots.
Sunday, July 24, 2011
Thursday, July 21, 2011
"Set Service Login" window during service installation from InstallUtil.exe
Often a prompt window named "Set Service Login" appears during windows service installation through "installUtil.exe" asking for user authentication
Best way to ignore it is by modifying properties in installer.cs class
-Change Account in ProcessInstaller to 'LocalSystem'
-And Start type in ServiceInstaller to 'Automatic'
It will work fine than.
Best way to ignore it is by modifying properties in installer.cs class
-Change Account in ProcessInstaller to 'LocalSystem'
-And Start type in ServiceInstaller to 'Automatic'
It will work fine than.
Debugging a windows Service
Though there are different ways to debug your code in windows service, I have often preferred to modify my default Program.cs class like:
static class Program
{
///
/// The main entry point for the application.
///
static void Main()
{
#if (!DEBUG)
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new LISService()
};
ServiceBase.Run(ServicesToRun);
#else
LISService lis = new LISService();
lis.Start();
#endif
}
}
static class Program
{
///
/// The main entry point for the application.
///
static void Main()
{
#if (!DEBUG)
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new LISService()
};
ServiceBase.Run(ServicesToRun);
#else
LISService lis = new LISService();
lis.Start();
#endif
}
}
Monday, May 30, 2011
Copy Assembly from GAC
An easy way to copy library file from GAC is to access C:\windows\assembly\GAC_MSIL from run command.
Monday, April 18, 2011
Copy on Clipboard using Javascript
I needed to have functionality of copying contents of textbox on clipboard at my aspx page. This is how I implement it
Objects:
Width="596px">
Script:
function CopyToClipboard()
{
var textboxVal = document.getElementById("txtScript").value; //txtText id of a textbox
if( window.clipboardData && clipboardData.setData )
{
clipboardData.setData("Text", textboxVal);
}
else
{
//alert("You should upgrade you browser,works only in IE4+");
}
}
Thursday, February 17, 2011
Disable an ASP.NET validation from Javascript
Below is a small code i used to disable my dotnet validators through javascript
var myVal = document.getElementById('MyvalidatorsClientId');
ValidatorEnable(myVal, false);
var myVal = document.getElementById('MyvalidatorsClientId');
ValidatorEnable(myVal, false);
where ValidatorEnable(Object, Enabled).
A sample could be
function CountryChanged()
{
var myVal = document.getElementById('ctl00_ContentPlaceHolder1_RfvtxtState');
ValidatorEnable(myVal, false);
}
Tuesday, January 18, 2011
Generate Random Alphanumeric Number
I used the following function to generate random alphanumeric code in one of my project
Public Shared Function GenerateRandomString(ByRef len As Integer, ByRef upper As Boolean) As String
Dim rand As New Random()
Dim allowableChars() As Char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ0123456789".ToCharArray()
Dim final As String = String.Empty
For i As Integer = 0 To len - 1
final += allowableChars(rand.Next(allowableChars.Length - 1))
Next
Return IIf(upper, final.ToUpper(), final)
End Function
Public Shared Function GenerateRandomString(ByRef len As Integer, ByRef upper As Boolean) As String
Dim rand As New Random()
Dim allowableChars() As Char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ0123456789".ToCharArray()
Dim final As String = String.Empty
For i As Integer = 0 To len - 1
final += allowableChars(rand.Next(allowableChars.Length - 1))
Next
Return IIf(upper, final.ToUpper(), final)
End Function
Subscribe to:
Posts (Atom)