SYSK 396: FxCop Rules for RESTful API

There are a few well known basic naming rules providing a consistent, understandable REST API services, e.g. The scheme and host name are not case sensitive; however, the path and query should be treated as case sensitive. Lowercase letters are preferred in URI paths.  Do use hyphens (-) between words to improve readability of URI…

0

SYSK 395: DataAnnotations: ConditionallyRequiredAttribute with lamda expressions

Back in 2010, Jeff Hanley published a sample of a ConditionallyRequiredAttribute that used a name of another property for runtime condition verification.  The original source can be found at http://jeffhandley.com/archive/2010/09/26/RiaServicesCustomReusableValidators.aspx.  I took the liberty to update it to support lambda expressions, allowing for more complex rules, e.g. [ConditionallyRequired(typeof(YourClass), “(x) => { return x.Prop1 == 5…

0

SYSK 394: Cost of getting StackTrace and finding a StackFrame

I wanted to find out the overhead of getting the stack trace and finding a specific method in the array of stack frames.  The profiled code looked like this: private static MethodBase GetCallerMethod(string caller) {     StackTrace st = new StackTrace(2);     return (from f in st.GetFrames() let m = f.GetMethod() where m.Name == caller…

0

SYSK 393: Error: Cannot obtain Metadata (RESOLVED)

Not all error messages are created equal, and some of them are less helpful than others.  Here is one I came across —  “Metadata contains a reference that cannot be resolved…  An exception was thrown in a call to a WSDL export extension:System.ServiceModel.Description.DataContractSerializerOperationBehavior contract…  Type ‘YourNamespace.YourClass’ cannot be serialized. Consider marking it with the DataContractAttribute…

0

SYSK 389: How to set ClientCredentials via Configuration file in Client

I’m working on a project where a service hosted elsewhere requires Windows authentication.  As a consultant, my computer is not on the customer’s domain, so, using my logged-on Windows credentials won’t do any good.  And, doing nothing results in the following exception:  “The caller was not authenticated by the service.” and inner exception is “The…

0

SYSK 387: Resolving Data Type Conversion Error

Consider the following line of code: AttendeeAvailability attendeeAvailability; . . .if (attendeeAvailability.WorkingHours.DaysOfTheWeek.Contains(DateTime.Today.DayOfWeek) == false){   . . . } You’ll get a compile time error — Argument 1: cannot convert from ‘System.DayOfWeek’ to ‘Microsoft.Exchange.WebServices.Data.DayOfTheWeek’   One way to resolve it is by converting it to a string representation and parsing into the Exchange library known data type,…

0

SYSK 386: Performance Implications of Using One vs. Several Nested Hashtables

Let’s say you need to quickly find some reference/lookup data and you decide to use hashtables…  If your key is comprised of several elements, is it better, from the performance point of view for you to combine all of them into one string and use it to access a flat single hashtable, or, would you…

0

SYSK 385: Smart Cache

John Manaloto, one of the architects I’ve worked with recently, has been kind enough to allow me to publish the “smart cache” class he’s put into one of his projects…  It’s a component built on top of Microsoft Caching Application Block from the enterprise library, but it has an additional capability of actually getting the…

0

SYSK 380: How to Get Rid of Double Scroll Bar in Microsoft Report Viewer Control

Special thanks to David Petersen who has submitted this post!   If you ASP.NET page that contains the Report Viewer Control, has double scroll bars, you can remove them by including two separate form elements on the page: 1.    First <form> element Includes your Headers and so forth (notice the absence of runat=”server” attribute in…

3