|
Reduce COM+ context overhead: activate in the caller's context
|
Total Hit (2675) |
Even though you may want to use some COM+ services, it doesn't mean that you have to have a unique context for each and every instance. The root instance, that is, the instance that the client uses, must have a context, but the secondary instances can often co-locate within the first context.
In
....Read More |
Rating
|
|
|
Convert DataReader to DataTable
|
Total Hit (3706) |
There is no direct way to convert dataraeader to datatable in ADO.net so I wrote this function which is really handy.
Happy Prpgramming...
|
Rating
|
|
|
Determine the size of a structure
|
Total Hit (4598) |
Unlike previous Visual Basic versions, under VB.NET you can't use the Len function to calculate the length of a Structure or a class. However, it is easy to get this information with the SizeOf static method of the System.Runtime.InteropServices.Mashal class, as in:
....Read More |
Rating
|
|
|
Convert a decimal value to binary, octal, or hexadecimal
|
Total Hit (6017) |
The ToString method of the Convert class lets you easily and quickly convert a decimal value into a string representation of that number to binary, octal, or hexadecimal base:
«Code LangId=2»' convert to binary
Console.WriteLine(Convert.ToString(11, 2)) ' => 1011
' convert to octal
Console.W
....Read More |
Rating
|
|
|
|
Faster string comparison with the Is operator
|
Total Hit (3200) |
.NET strings are objects, so what you store in a String variable is actually a reference to a String object allocated in the managed heap. Even though the VB.NET compiler attempts to hide the object nature of strings as much as it can - for example, you don't need to declare a String object with a N
....Read More |
Rating
|
|
|
EncodeBase64 - Encoding a string to base64
|
Total Hit (3042) |
«Code LangId=2»' Returns the input string encoded to base64
Private Function EncodeBase64(ByVal input As String) As String
Dim strBytes() As Byte = System.Text.Encoding.UTF8.GetBytes(input)
Return System.Convert.ToBase64String(strBytes)
End Function
«/Code»
....Read More |
Rating
|
|
|
AddBackslash - Append a backslash to a path if needed
|
Total Hit (4087) |
«Code LangId=2»
' Append a backslash (or any character) at the end of a path
' if it isn't there already
Function AddBackslash(ByVal Path As String, Optional ByVal ch As Char = "\"c) _
As String
If Not Path.EndsWith(ch) Then
AddBackslash = Path & ch
Else
AddBack
....Read More |
Rating
|
|
|
A general benchmarking class
|
Total Hit (2904) |
Many times we need to benchmark some routine or a block of code. This class will help you to benchmark a routine or a block of code.
«code LangId=2»Public Class BenchMark
Delegate Sub BenchmarkDelegate()
Enum BenchmarkModes
DontShow
Console
MessageBox
End
....Read More |
Rating
|
|
|
Create zero-elements arrays
|
Total Hit (2556) |
The .NET framework lets you create two types of "empty" arrays: unitialized arrays and arrays that are initialized with zero elements. Uninitialized arrays are actually array variables that are set to Nothing, whereas zero-element arrays are non-Nothing variables that point to arrays with zero eleme
....Read More |
Rating
|
|
|
Dec2Any - Convert a decimal number to any other base
|
Total Hit (3949) |
«Code LangId=2»' convert a positive number to any base
' BASE can be in the range 2-36
Function Dec2Any(ByVal number As Long, ByVal base As Short) As String
Dim index As Integer
Dim digitValue As Integer
Dim res As New System.Text.StringBuilder()
Const digits As String = "0
....Read More |
Rating
|
|
|
How Do I... Work with tracing?
|
Total Hit (2192) |
Trace instrumentation allows developers and administrators to monitor the health of applications running in real-life settings (as opposed to running in a debugger). Sometimes using a debugger can hide bugs and obscure some performance and threading problems. Tracing is a very important monitoring a
....Read More |
Rating
|
|
|
|
|
Copy Directory Content and All subfolders to target path
|
Total Hit (11309) |
This Code will copy all files and subfolders of specified source directory to target location
«code LangId=2» Sub CopyDirectory(ByVal SourcePath As String, ByVal DestPath As String, Optional ByVal Overwrite As Boolean = False)
Dim SourceDir As DirectoryInfo = New DirectoryInfo(SourceP
....Read More |
Rating
|
|
|
Setting up multiple start-up projects
|
Total Hit (2411) |
By default, a solution has a single start-up project, namely the project that is automatically launched when you click Debug | Start or press F5. However, you have the option to start multiple projects of the solution when you call Start, something that is very useful to automatically start, in debu
....Read More |
Rating
|
|
|
|
|
CompareList - Compare an argument with a list of values
|
Total Hit (2561) |
«Code LangId=2»' Return the position of the argument in a list of values
' or zero if the argument isn't included in the list
' It works for both regular values and for objects
'
' This handy function can often save you a lengthy Select Case
' statement or a complex series of If...ElseIf block
....Read More |
Rating
|
|
|
|
|
All about .NET Assemblies, GAC, Manifests and Deployment
|
Total Hit (3409) |
A .NET application is composed of three primary entities: assemblies, modules and types. An Assembly is the primary unit of deployment. The individual files that make up a .NET application are call modules. Types are the basic unit of encapsulating data and behavior behind an interface composed of
....Read More |
Rating
|
|
|
|
How Do I...Build a .NET Client That Uses a COM Server?
|
Total Hit (821) |
This section explains how to build managed code that uses COM. The steps involved in the build process are as follows:
«LI»Obtain an assembly containing definitions of the COM types to be used.
«LI»Install the assembly in the global assembly cache. (optional)
«LI»Reference the assembly conta
....Read More |
Rating
|
|
|
Introduction to .NET Reflection
|
Total Hit (1230) |
Reflection is ability to find information about types contained in an assembly at run time. Prior to .NET languages like C++ provided such ability in a limited sense. .NET provides a whole new set of APIs to introspect assemblies and objects. All the APIs related to reflection are located under Syst
....Read More |
Rating
|
|
|
How To: Host a Remote Object in a Windows Service
|
Total Hit (1270) |
Objects called using the .NET Remoting infrastructure can be hosted by ASP.NET, custom executables or Windows services. This How To shows you how to host a remote object in a Windows service and call it from an ASP.NET Web application.
|
Rating
|
|
|
ConsoleAttributes
|
Total Hit (1772) |
The ConsoleAttributes allows you to change the default behaviour of the console class. You can modify several attributes (like ForeColor, BackColor, Echo Input etc), and you can move the cursor around.
|
Rating
|
|
|
Creating Custom SOAP Extensions - Compression Extension
|
Total Hit (2237) |
Web Services have already been standardized and its usage if definitely on the rise. Developers are quickly finding new and better ways to apply Web Services in their existing or new application designs. Reviewing many of the Web Services designs I have noticed that developers are increasingly perfo
....Read More |
Rating
|
|
|
Life Without Control Arrays in Visual Basic .NET
|
Total Hit (1141) |
Control arrays were the best way to manage the controls on your Visual Basic forms, but there are no control arrays in Visual Basic .NET. Deborah Kurata describes how to use new Visual Basic .NET features to obtain control array functionality without the need for a control array.
....Read More |
Rating
|
|
|