SalesForce Canvas Library for .Net

https://github.com/short000/salesforce-canvas-dotnet SalesForce.com does not directly support CORS or JSONP for cross-origin resource sharing of an IFRAME; instead, they have their own implementation called SalesForce Canvas. Since SalesForce instances (and therefore your IFRAMEd application) must be exposed to the Internet, some validation is required. It involves reading an encoded “signed request” and comparing a hash of it … Read moreSalesForce Canvas Library for .Net

Asynchronous ADO.Net (BeginExecute/EndExecute)

Problem: we need to run a SQL command for one item synchronously (wait to avoid race condition), but then run it again asynchronously on a second set of items (“fire-and-forget”). We don’t need to wait on results from the second set of items and would also like to avoid timing out in case the second … Read moreAsynchronous ADO.Net (BeginExecute/EndExecute)

.Net Coding Standards

The C#/.Net coding style that I recommend is documented in MSDN: MSDN’s “Design Guidelines for Developing Class Libraries”: http://msdn.microsoft.com/en-us/library/ms229042 MSDN’s “Guidelines for Names”: http://msdn.microsoft.com/en-us/library/ms229002 For more in-depth guidance, I consult Microsoft’s authoritative book, Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries. Although it’s a bit pricey, it also includes a DVD with several video … Read more.Net Coding Standards

Reduce Exception Handling Bloat

Most developers are probably familiar with exception handling guidelines that advise you to “avoid catching System.Exception or System.SystemException, except in top-level exception handlers”, and “if you can’t handle the exception in your part of the chain, throw it upwards rather than swallow it”. These spirit of these guidelines basically encourage you to: Create your own typed exceptions … Read moreReduce Exception Handling Bloat

C#: Read or Write a File in One Line

If buffering and streaming performance aren’t required, here are six examples on how to use System.IO.File to read/write strings, string arrays, and byte arrays from/to a file in just one line without having to loop through blocks or worrying about closing or disposing: using System.IO; … const string inputFilename = @”c:\foo.dat”; string inString = File.ReadAllText(inputFilename); … Read moreC#: Read or Write a File in One Line