Saturday, April 24, 2010

VB.NET and C# Comparison

Great posting that compares VB.NET and C#:

http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

Friday, April 23, 2010

Sorting Collections (Generic.List)

Here is a simple example for sorting collections (such as a Generic.List) based on particular attributes in the objects:

http://stackoverflow.com/questions/438715/how-sort-a-system-collections-generic-list-in-vb-net

Here is another:

http://www.codedigest.com/Articles/CSHARP/84_Sorting_in_Generic_List.aspx

Serializing Objects in .NET as XML or Binary

This posting provides a good summary of serializing .NET Objects as XML or Binary:

http://devcity.net/Articles/113/1/dotnet_serialization.aspx

Wednesday, March 31, 2010

Rectangle Structure

Here is a pretty good link that shows all of the different results using the different method from the Rectangle class such as Union, Intersection, Inflate, etc.:

http://www.java2s.com/Tutorial/VB/0300__2D-Graphics/CreateRectangleFromSizeAndPoint.htm

Tuesday, March 2, 2010

Simple XOR String Encryption

Here is a posting I found on how to Encrypt Strings with an XOR operation:

http://www.eggheadcafe.com/tutorials/aspnet/8b53894c-a889-4914-8c46-122980cc44ae/simple-xor-encryption.aspx

Friday, February 19, 2010

Memory Mapped Files in .NET

Here is a link to info on using Memory Mapped Files in .NET:

http://weblogs.asp.net/gunnarpeipman/archive/2009/06/21/net-framework-4-0-using-memory-mapped-files.aspx

Friday, January 15, 2010

Setting the WCF MaxBufferSize, MaxReceiveMessageSize, and MaxArrayLength in Code instead of App.config

While the concept of using the app.config file for configuring the many WCF parameters is a nice idea. I sometime like setting the values in code. The most common one for me are MaxBufferSize, MaxReceiveMessageSize, and maxArrayLength because they are usually too small by default for most of my applications. Below I showthe app.config file with these parameters set and then how you can set the same parameters with code in C# and VB.NET.


app.config











VB.NET

' Increase binding max sizes so that the image can be retrieved
If TypeOf pltSvr.Endpoint.Binding Is ServiceModel.BasicHttpBinding Then
Dim binding As ServiceModel.BasicHttpBinding = _
CType(pltSvr.Endpoint.Binding, ServiceModel.BasicHttpBinding)
Dim max As Integer = 5000000 ' around 5M size allowed
binding.MaxReceivedMessageSize = max
binding.MaxBufferSize = max
binding.ReaderQuotas.MaxArrayLength = max
End If



C#

// Increase binding max sizes so that the image can be retrieved
if (pltSvr.Endpoint.Binding is System.ServiceModel.BasicHttpBinding)
{
System.ServiceModel.BasicHttpBinding binding =
(System.ServiceModel.BasicHttpBinding)pltSvr.Endpoint.Binding;

int max = 5000000; // around 5M
binding.MaxReceivedMessageSize = max;
binding.MaxBufferSize = max;
binding.ReaderQuotas.MaxArrayLength = max;
}