Visual Studio
Issues related to Visual Studio and the .NET Framework
Sometimes working with the js Serializer is easy, sometimes its not. When I attempt to serialize an object that is derived from a base, the serializer decided whether or not to include the type name. When its present, the type name is represented by a ___type attribute in the serialized json like this: {"d":{"__type":"Commerce.In... The missing type name is a problem if I intend to ship the object back into a web method that needs to deserialize the...
I was working on a project that required a determination if the type was an IEnumerable collection of some type. Using a bit of reflection and the handy-dandy GetGenericTypeDefinition method, I arrive at this: Code Snippet public static bool IsIEnumerableOfT(Type type) { return type.GetInterfaces().Any(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof (IEnumerable<>)) ; } Happy Coding...
I’m posting this here because I keep forgetting the syntax, and thought others might benefit as well. Given : public class ParentItem { IEnumerable<ChildItem> Children } Selecting all the childitem instances from an IEnumerable<ParentItem>: var allChildren = ParentItems.SelectMany(pare... Selecting matching childItem instances from an IEnumerable<ParentItem>: var selectedChildren = ParentItems.SelectMany(pare...
I’ve read some posts regarding this error when using the First() or Single() command. They suggest using FirstOrDefault() or SingleorDefault() instead. But I recently encountered it when using a Sum() command in conjunction with a Where(): Code Snippet var effectiveFloor = policies.Where(p => p.PricingStrategy == PricingStrategy.EstablishFl... => p.Amount); When the Where() function eliminated all the items in the policies collection, the Sum() command threw the “Sequence contains no...
If you attempt to make an ajax call that cross domain or protocol boundaries, the default XHR (XmlHttpRequest) processor will fail. The out-of-the-box implementation forbids crossing boundaries. Enter flXHR. A flash-based proxy that implements (and extends) the XHR API. That’s good news for JQuery developers. It means you can use flXHR just like the native Jquery XHR. There’s also a Jquery proxy plugin that makes it SIMPLE. You can download the sample here. In my example, I’m hosting the website...
I found this fix online which appears to have resolve this issue, so I wanted to share it here. I take no credit/responsibility for it, except to say that it has resolved the issue for me. Set the 32-bit flag on resgen.exe a. Open a Visual Studio command-prompt as an administrator b. Navigate to the Microsoft SDKs\Windows\v7.0A\bin directory. c. ***SAVE A COPY*** of your original resgen.exe file. This is very important if you want to be able to replace our tweak with the original file without having...
Supposedly, HTTPPostedFile.FileName is supposed to contain just the name of the uploaded file. It should exclude the original filename path. This doesn’t always appear to be the case, and seems to vary by the browser doing an upload. To avoid the browser issue entirely, use a FileInfo(HttpPostedFile.Fil... to return just the file name (and extension) portion of the file. Change this: Code Snippet var saveFileName = Path.Combine(UploadedFileSe... FilePackage.PostedFile.File... to this:...
Many of the examples of databinding use datasource or objectsource controls. I prefer to databind from the code-behind. I feel I have finer control over how to data is prepared before I load it. The downside to doing this “late binding” of the data, and I can’t use the strongly typed names in my declarative markup. The following code fails because the compiler can’t resolve the “Products” reference. Code Snippet <asp:DataList ID="DataList1" runat="server" RepeatColumns="1" DataSource='<%#Products%...
Code Snippet ThreadPoolHelper.QueueUserW... arg2, arg3, (localArg1, localArg2, localArg3) => { /* code block */ });...
I recently attempted to install a windows service I had created. I created an installer and deployed the msi to the target machine. When I ran the setup I was prompted for the username and password credentials for the identity to run the service. I had a local account created. The account was permissioned correctly and had been granted the rights to logon as a service. After supply the credentials, the I received the following error: Error 1001. The account name is invalid or does not exist, or the...
Full Visual Studio Archive