WCF Best Practices: How to Dispose WCF clients

30 ביולי 2008

Use of the using statement (Using in Visual Basic) is not recommended for Dispose WCF clients. This is because the end of the using statement can cause exceptions that can mask other exceptions you may need to know about.using (CalculatorClient client = new CalculatorClient()){...} // <-- this line might throwConsole.WriteLine("Hope this code wasn't important, because it might not happen.");The correct way to do it is:try{...client.Close();}catch (CommunicationException e){...client.Abort();}catch (TimeoutException e){...client.Abort();}catch (Exception e){...client.Abort();throw;}

Tune your .NET Application that suffer from contention, poor performance, and deadlocks

29 ביולי 2008

Hi, If you develop .NET application that uses: CLR thread pool You have available CPU cycles Your application performs I/O bound operations such as calling a Web method or accessing the file system The ASP.NET Applications/Requests In Application Queue performance counter indicates that you have queued requests If you are unsure whether your application is using the CLR threat pool you can check as follows. Your application may be using the CLR thread pool if any of these conditions is true: Your application makes Web service calls. Your application uses the WebRequest or HttpWebRequest classes to make outgoing Web requests. Your application explicitly queues...

Customize your .NET object XML serialization with .NET XML attributes

27 ביולי 2008

Hi, Serialize .net object to XML is very simple operation but let's say you want to control on the serialization and decide on the name of the XML attributes and elements that .net serialization create for your object. Well this is very simple to achive using built-in XML attributes (attributes like: XmlType, XmlAttribute, XmlArray, XmlArrayItem and more...) .NET gives us. The code example include 3 classes: MainStory, Story and BaseStory. MainStory and Story both inherits from BaseStory, MainStory also contain list (List<Story>) of stories objects. BaseStory: public class BaseStory {     protected const string DescriptionContentDelimiter = ":::";           public string Content { get; set; }           public...

Parsing log files

13 ביולי 2008

Hi, Have you ever got a task that required reading and parsing log files? Well Log Parser 2.2 is the tool for you. Log parser is a powerful, tool that provides SQL query syntax to text-based data such as log files, XML files and CSV files. It also support Windows operating system files such as the Event Log, Registry, the file system and Active Directory. You tell Log Parser what information you need and how you want it processed. The results of your query can be custom-formatted in text based output, or they can be persisted to more specialty targets like SQL, SYSLOG, or a chart. There...
no comments

Nice wrapper for .NET ConfigurationManager

7 ביולי 2008

I wrote a nice and useful wrapper class for .NET ConfigurationManager class. What this class gives you: Internal cache for reading AppSettings values. The cache refresh itself when the file is change on the fly. (Just use Setting.Watch()) You can read parameters from AppSettings section with generic support and also forward default value. You can read connection string and more...Basically you can start working with the wrapper class instead of using .NET ConfigurationManager class. Of course you can change and add more functionality to the class that will suit your needs. For example you can use the code: bool isAllow = Setting.Get<bool>("MyAppSettingsKey"); Please add your comments, You...

How to Hoste Windows Live Messenger IM Control in you web site

Hi, Adding messenger icon to your blog\web site and give your readers the ability to send you direct message to your messenger is very simple. Go to: Windows Live Messenger Web Setting page and mark the checkbox "Allow anyone on the web to see my presence and send me messages". After that go to Windows Live Messenger Create HTML and select your icon. More information can be found on MSDN: Hosting the Windows Live Messenger IM Control
no comments

WCF Tips: Achieving High Performance. List of Key Design Decisions and Tuning Parameters

3 ביולי 2008

When working with WCF especially when middle-tier client applications uses Windows Communication Foundation, you sould always think about performance and take some major design decisions and tuning parameters. WCF client not generated as a proxy via SvcUtil.exe (Relevant more in .NET 3.0. In .NET 3.5 major performance improvement was made on WCF proxy creation). Client shares service contract and schema (model classes as data contract). Cache WCF proxy as a static member One instance, once instance only, ever Still thread-safe based on WCF under-the-covers network connection pool managementChannels created directly via ChannelFactory Hidden static channel exposed as a property Getter/Setter logic does all initialization/abort/recreation as necessary Maintains clean...
8 comments

Did you know that svcutil with /r does not work for MessageContract

I was trying to generate WCF proxy (Client) using svcutil.exe Visual Studio 2008 version. I also need to use the /r parameter of the svcutil.exe, so the generated proxy code will not generate definition for the objetcs from my reference assemblies.The command I use is something like:svcutil.exe /async http://localhost:8080/MyService /r:"C:\My.dll" /tcv:Version35 /out:MyClient.csIn case the assembly My.dll contain .NET object that mark as  the generated proxy still contain definition for the MessageContract objects, so I have to change these objects to DataContract objects and then the generated proxy was created as expected.You also need to remember that if your reference...

Useful commands extensions for Visual Studio 2008 IDE

Hi All, PowerCommands for Visual Studio 2008 add some new useful commands for VS 2008 IDE. Below is a list of the included in PowerCommands for Visual Studio 2008: Enable/Disable PowerCommands in Options dialogThis feature allows you to select which commands to enable in the Visual Studio IDE. Point to the Tools menu, then click Options. Expand the PowerCommands options, then click Commands. Check the commands you would like to enable.Note: All power commands are initially defaulted Enabled.Format document on save / Remove and Sort Usings on saveThe Format document on save option formats the tabs, spaces, and so on of the document...
one comment