Monday, April 27, 2009

Using Enums

Hi Guys,
Here are the useful methods that can be utilized against the Enums:


Public Enum WeekDays
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
End Enum

1. The following method helps easily to load the enum names to the combo/list box
Example:
lstWeekDays.Items.AddRange([Enum].GetNames(GetType(WeekDays)))
2. The following method helps easily to load all the enum values at once to an array
Example:
dim myArray as Array = [Enum].GetValues(GetType(WeekDays))
3. The following method helps easily to determine if a name or a value exists in the Enum
Example:

if [Enum].IsDefined(GetType(WeekDays), "Sunday") Then 'do something
If [Enum].IsDefined(GetType(WeekDays), 1) Then ' do something its Monday

Monday, April 20, 2009

Load a ComboBox with Installed Fonts

Hi Guys,
Here's an easiest way to load all the installed fonts to a combo box.
myComboBox.Items.AddRange (System.Drawing.FontFamily.Families);
That's it.

Reversing a string

The easiest way to reverse the string is as follows:

char[] actualDataInArray = myStringData.ToCharArray();
Array.Reverse(actualDataInArray);
string reversedString = new string(actualDataInArray);

That's it.

Tuesday, April 14, 2009

Microsoft Code Analysis Tool .NET

Hi Guys,
CAT.NET is a snap-in to the Visual Studio IDE that helps you identify security flaws within a managed code (C#, Visual Basic .NET, J#) application you are developing. It does so by scanning the binary and/or assembly of the application, and tracing the data flow among its statements, methods, and assemblies. This includes indirect data types such as property assignments and instance tainting operations. The engine works by reading the target assembly and all reference assemblies used in the application -- module-by-module -- and then analyzing all of the methods contained within each. It finally displays the issues its finds in a list that you can use to jump directly to the places in your application's source code where those issues were found. The following rules are currently support by this version of the tool. - Cross Site Scripting - SQL Injection - Process Command Injection - File Canonicalization - Exception Information - LDAP Injection - XPATH Injection - Redirection to User Controlled Site. You can download this package here.

Wednesday, March 11, 2009

Getting Started with the .NET Task Parallel Library

Hi Guys,
Microsoft's new Task Parallel Library (TPL) provides a new approach for using multiple threads. It provides a set of relatively simple method calls that let you launch a group of routines all at once. This article provides an introduction to TPL. It explains the main pieces of TPL and provides simples examples. Know more...

Tuesday, July 29, 2008

Error: The name 'instance-variable' does not exist in the current context

Recently I got the following error "The name 'instance-variable' does not exist in the current context" where 'instance-variable' was the member variable of one of my page.  I was really confused as I was sure that I was doing it right.  So what else could be the problem?  Well it turns out that I had made a backup copy of the file in the same directory before I had changed it.  I turns out that in a Asp.Net 2.0 website you can't have two ASP.NET pages or user controls with the same name class name.  Because the pages are partial classes it does not give the error "The namespace 'global-namespace' already contains a definition for 'instance-variable'" like you would normally get if you redefined a class.  Read more here...

Thursday, June 05, 2008

Microsoft ACT standalone installation

Microsoft ACT is great for stress testing web sites. The only "problem" is that you have to install Visual Studio .NET in order to use it. I use it frequently on my dev machine but some times it is useful have it on a remote machine for stress testing directly in a pre-production environment. The steps below shows how you can copy your local ACT installation to a standalone computer.

Pre-requisite: Internet Explorer 6.0

Steps by step instructions:

  • Copy the C:\Program Files\Microsoft ACT directory from you dev PC to the same directory on the remote machine
  • Create the Act.Reg and Register.cmd files below
  • Execute Register.cmd
  • Create a local user: ACTUser with the "User" rights
  • Set the Identify of the following COM objects to ACTUser (using dcomcnfg):
    • Application Center Test Broker
    • Application Center Test Controller
  • Give full control to ACTUser on the following WMI namespace using "Computer Management": Root/CIMV2/Application/MicrosoftACT


== Save as Register.cmd ==
c:
cd "C:\Program Files\Microsoft ACT"
regedit -s act.reg
for %%i in (*.dll) do regsvr32 /s %%i
ACTBroker.exe -regserver
actcontroller.exe -regserver
ACTRegMof.exe -i "C:\Program Files\Microsoft ACT\actnamespace.mof"
ACTRegMof.exe -i "C:\Program Files\Microsoft ACT\actbroker.mof"
ACTRegMof.exe -i "C:\Program Files\Microsoft ACT\actcontroller.mof"


== Save as Act.Reg ==
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ACT]
"AppPath"="C:\\Program Files\\Microsoft ACT\\"
"ProductCode"="{E05F0409-0E9A-48A1-AC04-E35E3033604A}"
"Feature"="AppCenter_Test_for_VS.NET"
"Version"="1.0.0536"

Disclaimer: Follow the instructions at your own risk and make sure you have a working backup!

Tuesday, March 27, 2007

Patterns and Software: Essential Concepts and Terminology

Patterns for software development are one of the latest "hot topics" to emerge from the object-oriented community. They are a literary form of software engineering problem-solving discipline that has its roots in a design movement of the same name in contemporary architecture, literate programming, and the documentation of best practices and lessons learned in all vocations. Learn more...

Friday, May 19, 2006

Gaining Remote Access to Microsoft Access with RDO

The following tutorial shows how to use the RDO control, which is similar to the ADO control, to access a Microsoft Access Database on a network drive from a machine on another node of the network. Learn more...

Thursday, May 18, 2006

LINQ Into Microsoft's New Query Capabilities

At PDC 2005, Microsoft introduced brand new technology known as LINQ, which stands for "Language Integrated Query."

The feature set hiding behind this acronym is truly mind-boggling and worthy of a lot of attention. In short, LINQ introduces a query language similar to SQL Server's T-SQL, in C# and VB.NET. Imagine that you could issue something like a "select * from customers" statement within C# or VB.NET. This sounds somewhat intriguing, but it doesn't begin to communicate the power of LINQ. LINQ represents the ability to apply query-style syntax to objects rather than just data sources. This difference, as well as some of the implementation specifics, makes LINQ significantly more powerful than other query languages. Learn more...

Monday, February 27, 2006

Make Your ASP.NET Applications Talk with Text-to-Speech

Text-to-Speech (TTS), also known as speech synthesis, is the process in which typed text is transformed into audible speech. This is preferable to pre-recorded text in which it must be known ahead of time exactly what must be said. With text-to-speech there are opportunities to introduce information that is dynamic. The dynamic information could be from a database or a case where text spoken by a user is repeated for confirmation. Read more...

Monday, February 20, 2006

Filtering HTTP Requests with .NET

ASP.NET has a number of extensibility points that developers can use. One such point is response filtering, accessible via the Filter property of the HttpResponse class. Filters intercept content destined for the client and have an opportunity to modify that content prior to sending it out. Filters are unique in that they can access the raw byte stream that is going to be sent to the client. Read more...

Friday, February 17, 2006

DataGrid/GridView Paging and Sorting Using A DataReader - Introduction

Now, the Datareader is forward-only right? Hmm, but what about paging and sorting? Can we natively implement a DataReader to provide paging and sorting as one would typically with a DataSet? The answer unfortunately is no, and if you try doing this you receive this error message:

AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID DataGridID when AllowPaging is set to true and the selected datasource does not implement ICollection.

Read more...

Roaming Web Applications in Visual Studio 2003

Visual Studio 2003 provides a nice development environment for creating ASP.NET web applications. However, it has significant shortcomings that create difficulties in a school lab environment: in order to debug ASP.NET applications, the user must

Run IIS on the local workstation

Have administrator-level privileges to the local workstation

Store project files on the c: drive

In a lab environment, it is usually not desirable for users to have administrative privileges on the workstations, and it is preferable for project files to be stored on a network server, rather than a local workstation drive. Read more...

Nine Options for Managing Persistent User State in Your ASP.NET Application

ASP.NET provides many different ways to persist data between user requests. You can use the Application object, cookies, hidden fields, the Session or Cache objects, and lots of other methods. Deciding when to use each of these can sometimes be difficult. Read more...

Don't Use Select *

Something you see in a lot of database access code is a select statement that looks something like this:

SELECT * FROM TableName WHERE ...

While there's technically nothing wrong with it, using the SELECT * syntax could be stealing away precious performance from your application, and even it it's not now, it might someday soon. Read more...

Saturday, February 04, 2006

A Developer's Introduction to VoIP

Voice over Internet Protocol applications aren't just for telecommunications programmers working on phone switches. Thanks to emerging technologies and standards, enterprise programmers and commercial developers can leverage voice technologies in traditional Web, desktop and server software. Not familiar with VoIP? You're not alone. This primer will help. Read more...

Google Maps and ASP.NET - Building a custom server control

I am sure that most of you have heard about or have had a chance to use Google Maps. It's a great service and I was really impressed by the responsiveness of the application and the ease with which users could drag and zoom maps from a Web browser. It has in many ways heralded the arrival of AJAX (Asynchronous JavaScript and XML), which I am sure will revitalize Web development in the days to come. Read more...

GnuPG Encryption for Email, XML, and Others in a VB.NET Wrapper

For email there is only one security standard that is highly used--PGP or the public domain version GnuPG. Read more...

Sending Email with AJAX

AJAX has become ubiquitous, thanks to the fact that it gives web developers the ability to create applications that make http requests without reloading the page on which the application is running. It is also extremely versatile and powerful. Read more...

Read Part 2

Read Part 3