Tag Archives: install window sevice

csharp basics

csharp basics

csharp basics

Q Solve following exceptions details:

“Exception Details: System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the
neutral culture. Make sure “AjaxControlToolkit.Properties.Resources.NET4.resources” was correctly embedded or linked into assembly
“AjaxControlToolkit” at compile time, or that all the satellite assemblies required are loadable and fully signed.”

Solution:  Add following to form:

<asp:Content ID=”BodyContent” runat=”server” ContentPlaceHolderID=”MainContent”>
<asp:ScriptManager ID=”ScriptManager1″ runat=”server”>


</asp:Content ID>

asp:ScriptManager tag should be put under asp:Content tag i.e. inside Content pages.

How to Install a window service ?

1. Run cmd prompt as “Run As administrator”

2. on command prompt type:

Path= C:\Windows\Microsoft.NET\Framework\v4.0.30319

3. Check if path is set typing path on cmd prompt

4. installUtil -i <Name of exe> (Name of exe is the exe file in built folder) {install the service}
5. installUtil -u <Name of exe> {uninstall the service}
6. Start/Stop service from services.msc
7. Set start mode to “Automatic” and Recovery  to “restart service”

8. Add name of the service in InitialiseComponent() function as :this.serviceInstaller1.ServiceName = “WinServiceTemp”;

9. Give Service account credentials as LocalSystem so while installation .. username and password is not asked:

 this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem; 

Fill dropdownlist with data from datatable  ?

DropDownList1.DataTextField = “Severity_type”; // Here Severity_type is name of the table attribute 

Create random password

public static string CreateRandomPassword(int passwordLength)
string allowedChars = “abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789_”;
char[] chars = new char[passwordLength];
Random rd = new Random();

for (int i = 0; i < passwordLength; i++)
chars[i] = allowedChars[rd.Next(0, allowedChars.Length)];

return new string(chars);

 sorting a datatable by column in c#

DataTable table = new DataTable();

table = getQueryResult(); // a function returning a datatable

table.DefaultView.Sort = “Id desc”; // where id is the column by which data table has to be sorted

table = table.DefaultView.ToTable();

adding an auto_increment column to a data table c#

DataTable dtIncremented = new DataTable(table.TableName);

DataColumn dc = new DataColumn(“Sr No.”);

dc.AutoIncrement = true;

 dc.AutoIncrementSeed = 1;

 dc.AutoIncrementStep = 1;

dc.DataType = typeof(Int32);



 DataTableReader dtReader = new DataTableReader(table);



//GridView.DataSource = dtIncremented; // set  data source to this data table