RSSAll Entries in the ".NET" Category

Retrieving domain information through ASP.NET

Retrieving domain information through ASP.NET

There are many  domain checking websites available that gives all the information regarding domains. WhoIs is one of them. Following is a sample asp.net code that connects to one of WhoIs servers and retrieve information of a specific website.
using System; using System.Collections.Generic; using System.Linq; [...]

Add meta data dynamically

Add meta data dynamically

Add meta-data dynamically to your page by adding a HtmlMeta control to your Header. In this example I dynamically add a keyword string to the page.
string keyWords = “metatags, html, dynamic, generate”;
HtmlMeta keywords = new HtmlMeta();
keywords.Name = “keywords”;
keywords.Content = keyWords;
Page.Header.Controls.Add(keywords);

Date Time string formatting in ASP.NET

Date Time string formatting in ASP.NET

With the following code you can format a DateTime within a Databind.
<%# DateTime.Parse(Eval("DateModified").ToString()).ToString("MM-dd-yyyy")%>

Some more format specifiers that can change format of datetime objects the way it is required.

Format specifier
Name

d
Short date pattern

D
Long date pattern

t
Short time pattern

T
Long time pattern

f
Full date/time pattern ( short time )

F
Full date/time pattern ( long time )

g
General date/time pattern ( short time [...]

SqlBulkCopy – Bulk Insertion in SQL Server from .NET

SqlBulkCopy – Bulk Insertion in SQL Server from .NET

Many a times there come a scenario when you have to insert large number of records in sql server. There are number of ways to implement this scenario:

through looping techniques to call insert statements for one record at a time.
Serialize the data in CSV or XML format and send them as a parameter to a [...]

Crystal report tutorial - VS 2005

Crystal report tutorial – VS 2005

A very good book on using Crystal reports in Visual Studio 2005. many small and minute things are discussed in this book.
VS2005 Walkthroughs Crystal Reports

Easy way to Export dataset in Excel

Easy way to Export dataset in Excel

Fastest way to export dataset in excel format is:

DataSet dsExport = new DataSet();
System.IO.StringWriter tw = new System.IO.StringWriter();
HTMLTextWriter hw = new HTMLTextWriter(tw);
DataGrid dg = new DataGrid();
dg.DataSource = "Dataset to be exported"
hw.WriteLine ("<b><font size=’3′>Exported report</font></b>");
dg.DataBind();
Response.ContentType = "application/vnd.ms-excel";
EnableViewState = false;
Response.Write(tw.ToString());
Response.End();

Crystal Report Viewer width – Visual Studio

Crystal Report Viewer width – Visual Studio

By default Crystal report viewer width is fixed according to it toolbar, but changes due to amount of data present in the report. And the width is not editable (as it is seen). Because of this reason if a crystal report has good amount of data then it goes past page width and disturbs the [...]

Setting Windows Service account dynamically

Setting Windows Service account dynamically

Often we need to change the windows service account to our needs or when a new user is logged in who has not installed the service. Here is a quick way to check and change the service account.
string objPath = string.Format("Win32_Service.Name=’{0}’", serviceName); using (ManagementObject service = new ManagementObject(new ManagementPath(objPath))) [...]

The maximum report processing jobs limit configured by your system administrator has been reached.

The maximum report processing jobs limit configured by your system administrator has been reached.

call Close or Dispose method at the end so the reporting engine remove the report entry from its queue.

MS Charts in Visual Studion 2008

MS Charts in Visual Studion 2008

Looking for some good looking and lightweight charting control to be used with VS 2008 applications.
I have checked the following article on adding an using MS Charts control in vs 2008. It contains all the basic information regarding the creation and implementation of ms chart controls.
MS Charts
MS Charts Download
Chart Templates

Compile c++ DLL to 64 bit using VS 2003

Compile c++ DLL to 64 bit using VS 2003

HI,
Do the following things to compile it to 64-Bit application ———————————————————–
1) Open from the start menu "Microsoft Platform SDK for Windows Server 2003 SP1\Open Build Environment Window\Windows Server 2003 64-bit Build Environment\ Set Win Svr 2003 x64 Build Env (Retail)"(if didn’t find this, please install [...]

SetWindowLong Function doesn’t work in 64 bit machine

SetWindowLong Function doesn’t work in 64 bit machine

The SetWindowLong function changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory.
This function has been superseded by the SetWindowLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Microsoft Windows, use the SetWindowLongPtr function.

How to reg 64-bit assembly using VS2005 setup on 64-bit

How to reg 64-bit assembly using VS2005 setup on 64-bit

I got one problem on registering a 64bit assembly during theinstallation. The installation package was developed using VS2005setup project.I could not invoke this assembly after installation. I believe thereason is the assembly had not been registered properly duringinstallation.(The assembly works well if I run Framework64/regasm.exe manually ) Ialready set the Register property of the assembly [...]

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first

This annoying error comes up when using some smtp server that uses SSL.
A simple implementation to configure smtp settings in an ASP.NET web application is to add these setting in the specific "MailSettings" tag of Web.config file. I had also declared all the settings in web.config file but still I get this every time i [...]

Securing ASP.NET Web applications - Beginner's article

Securing ASP.NET Web applications – Beginner’s article

Want to secure a web application. A very good article relating to ASP.NET web application security hacks, and prevention techniques are defined at a beginner level. A good article for beginners, those who want to secure their applications.
Article Here

Disabling Repair option from installer

Disabling Repair option from installer

I was facing problem to disable “Repair” option from msi installer. I found the solution in little time.

If you haven’t install MSI ORCA then install it.
Open the msi file in MSI ORCA editor.
Select “Property” from left pane (Table pane), and Right click and ‘Add Row’ with property name ‘ARPNOREPAIR’ and value ‘1′ .
Save it and [...]

Disabling "Change" option from installer

Disabling “Change” option from installer

I was facing problem to disable “Change” option from msi installer. I found the solution in little time.

If you haven’t install MSI ORCA then install it.
Open the msi file in MSI ORCA editor.
Select “Property” from left pane (Table pane), and Right click and ‘Add Row’ with property name ‘ARPNOMODIFY’ and value ‘1′ .
Save it and [...]

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154

Sometimes when working with office Interop assemblies the above mentioned error occurs. I had also got the same when using Microsoft Excel interop assembly and adding its reference in my ASP.NET application.

 
 
 
The problem is that by default when Microsoft Excel is used as a COM object then it can only be activated by the [...]

Registering an Assembly through code

Registering an Assembly through code

Many times we have to register an assembly and only one thing came in mind "regasm" command line utility. But for this also we have to manually type this command and it parameters (assembly name) in command prompt, or we can use the Process class in .NET to call regasm executable, and run through .NET, [...]

Register an assembly through a setup project

Register an assembly through a setup project

In your setup project, make sure you selected the option to add an assembly and not the option to add a file. After you add the assembly, select it in the view pane and open the Properties dialog. The "Register" property should have a drop down list of the available registration options for the assembly. [...]