Contact   •   Articles   •   Products   •   Search

Rick Strahl's Web Log

Wind, waves, code and everything in between...
ASP.NET • C# • HTML5 • JavaScript • AngularJs

WebLog Posts in Category .NET


Adding Files to the Windows MRU/Recent Document List



In this post I talk about adding shortcut files to the Windows Most Recently Used (MRU) list that is also used for task bar icon Jump Lists. There are easy APIs that let you add associated files to your application's MRU. With a little extra work you can also read this list inside of your own applications so you can build your application specific MRU lists and let Windows manage the storage of the linked references rather than your own configuration. Here's how.

Prettifying a JSON String in .NET



Occasionally it's useful to prettify an existing JSON string that you've received from somewhere: An HTTP response you need to look at while debugging or a UI that needs to display JSON to the user. Here's a small tip that makes it easy to take a JSON string and prettify it using the JSON.NET library.

Bitmap types, Binary Resources and Westwind.Globalization



I've been working on supporting binary resource imports via the Web interface using Westwind.Globalization and I'm debating on whether supporting the .NET convention of importing image resources as Bitmaps is prudent. Bitmaps are rather unwieldy to use and are painful to export to common stream or file formats due to the funky 30 year old encoding architecture used by GDI+. In this post I talk about some of the issues I've run into with Bitmaps and why I'm considering importing resources simple as raw byte data.

Back to Basics: UTC and TimeZones in .NET Web Apps



Storing dates in persistent storage using UTC dates is a widely accepted best practice. But it's surprisingly complex using date data effectively if you want to let the user see dates and query data in their local time zone. Looking around I noticed that there's not a lot of comprehensive info on this topic, so I decided to take notes and write down some of the approaches I've used in this post. This post combines and overview and a number of helper routines specifically geared towards user timezone adjustments in typical ASP.NET Web applications.

Adding non-NuGet references to the new vNext Projects



vNext projects depend on NuGet packages to reference external dependencies. But vNext projects also support 'classic' .NET targets and the Full CLR vNext both of which support and even require assembly references in order to access core .NET functionality. In this short post I describe how you can reference external assemblies in non-vNext and FullClr vNext targets in vNext projects.

Blend Path interfering with C# Project Builds



Ran into a nasty Visual Studio error today that caused a compiler error related to an errand assembly reference from Visual Studio Blend. Blend? I don't even use Blend, and this is a Web Project. Here's what the problem is and how to get around it with a temporary hack.

Gotcha: Entity Framework gets slow in long Iteration Loops



I've been running into a common issue with Entity Framework where using a dbContext through many context operations can drastically slow down Entity Framework performance. Here's a quick overview of the problem and how to work around it with a few minor tweaks.

Updating Assembly Redirects with NuGet



There's little known NuGet command that allows you to re-create assembly redirects for all NuGet packages in your project or an entire solution.

Capturing Performance Counter Data for a Process by Process Id



Process specific Performance Counters in .NET work directly only with Process Names, not Process Ids which can be problematic if you need to monitor performance of multiple instances of the same process. In this post I describe how you can capture multiple processes uniquely and monitor each individually.

A .NET QueryString and Form Data Parser



.NET is a bit short when it comes to tools that can manipulate UrlEncoded data. If you need to read, create or modify raw querystrings or form data outside of ASP.NET's System.Web context there isn't a clean way to do this and even there if you want to modify url encoded data you'll need to write some code. This article describes a UrlEncodingParser class that lets you read in raw query strings, form data or entire URLs, then lets read, add and update values and then write the values back out. Makes you wonder why that functionality doesn't exist natively somewhere in .NET, eh? Code and samples are provided.

Using FiddlerCore to capture HTTP Requests with .NET



If you have an application that needs to capture HTTP or monitor HTTP traffic, FiddlerCore is the tool you can use to do it easily. In this post I demonstrate how easy it is to integrate FiddlerCore into an application to capture HTTP requests and save the data, as well as discuss how to deal with configuring FiddlerCore for SSL Certificate installation for HTTPS captures.

Nuget Dependencies and latest Versions



NuGet is a great component distribution mechanism and it's awesome for consuming components and getting them into projects. However, creating NuGet packages and getting the version dependencies worked out reliably has been a challenge. Specifically the way dependency versions are pulled in by NuGet are somewhat counterintuitive. In this post I look at some of the issues and bring up some thoughts of how this could work better.

Westwind Application Configuration Updates



I've recently updated my code-first, class based application configuration library with a number of features and updates. This blog post discusses some of the changes and new features of this useful library.

Using .NET HttpClient to capture partial Responses



Recently I needed to create a high volume monitoring application that retrieves a huge number of HTTP requests, and I need to minimize the amount of data pulled from these requests. In this post I describe some of the limitations in actually pulling an exact amount of data from an HTTP and Tcp/IP connection in .NET.

Dynamically loading Assemblies to reduce Runtime Dependencies



Using a static language like C# tends to work with hard assembly bindings for everything. But what if you want only want to provide an assembly optionally, if the functionality is actually used by the user? In this article I discuss a scenario where dynamic loading and activation made sense for me and show the code required to activate and use components loaded at runtime using Reflection and dynamic in combination.

Fixing a SkyDrive Sync Disaster



Recently I ran into a major sync problem with SkyDrive, where SkyDrive decided to update my synced folders with older data from the server, overwriting newer local files. After mangling thousands of files I ended up creating a small utility that lets me look and update these files in bulk. This post discusses the issues and provides a utility to facilitate fixing the problem.

Setting up and using Bing Translate API Service for Machine Translation



Public translation APIs as a Web Service are great for doing machine translation within applications or casual translation for user input in many applications. With Google recently removing Google Translate API I've been looking at alternatives and so wanted to hook up to the still supported Bing Translate API. Unfortunately the signup process for the Translate API is terrible, although using the service is easy enough once signed up. In this post I discuss step by step how to sign up and how to use the Translate API.

A small, intra-app Object to String Serializer



On a few occasions I've needed a very compact serializer for small and simple, flat object serialization, typically for storage in Cookies or a FormsAuthentication ticket in ASP.NET. XML and JSON serialization are too verbose for those scenarios so a simple property serializer that strings together the values was needed. Originally I did this by hand, but here is a class that automates the process.

Sql Connection Strings in .Config Files vs. Source Control



Connection strings in projects under source control can be problematic. Each Source Control user can potentially have different connection settings to use a database connection and these differences can't be easily reconciled via Source Control. Here are a couple of approaches that have worked for me to deal with this issue.

Building a better .NET Application Configuration Class - revisited



Managing configuration settings is an important part of successful applications. It should be easy to ensure that you can easily access and modify configuration values within your applications. If it's not - well things don't get parameterized as much as they should. In this post I discuss a custom Application Configuration class that makes it super easy to create reusable configuration objects in your applications using a code-first approach and the ability to persist configuration information into various types of configuration stores.

Process.Start() and ShellExecute() fails with URLs on Windows 8



It appears that on Windows 8 there's a bug in the ShellExecute() API that causes failure in URL navigation when running under Administrative privileges.

Back to Basics: When does a .NET Assembly Dependency get loaded



Assembly loading in .NET is often a cause of confusion. So many times I've heard how evil it is to add a reference to some big assembly, if it's just a minor feature. But .NET is really smart in assembly loading and by default uses just in time loading of referenced assemblies. In this post I review when assemblies are loaded with a few simple examples that demonstrate the process.

A tiny Utility to recycle an IIS Application Pool



Here's a small console app to recycle an Application Pool which seems to be something I've needed to do repeatedly in the past.

Creating STA COM compatible ASP.NET Applications



When it comes to deploying STA COM components in ASP.NET only WebForms has native support for STA component. Other technologies like MVC, ASMX Web Services and WCF run only in MTA mode. If you need to run your STA COM Components in ASP.NET here is what you need to know and a few tools that help you create STA compatible handlers.

Using JSON.NET for dynamic JSON parsing



Parsing JSON dynamically rather than statically serializing into objects is becoming much more common with today's applications consuming many services of varying complexity. Sometimes you don't need to map an entire API, but only need to parse a few items out of a larger JSON response. Using JSON.NET and JObject,JArray,JValue makes it very easy to dynamically parse and read JSON data at runtime and manipulate it in a variety of different ways. Here's how.

.NET 3.5 Installation Problems in Windows 8



I ran into a major headache with getting .NET 3.5 properly on my Windows 8 install - although installed SP1 was missing and wouldn't properly install. Here's what happened, how to check for the version actually installed and how to work around it.

Basic Spatial Data with SQL Server and Entity Framework 5.0



Spatial data has been available for a while in SQL Server, but if you wanted to use it with Entiry Framework you had to jump through some hoops. In this post I show how basic SQL Spatial data works and then how you can utilize the new features in EF 5.0 to directly access spatial data using your CodeFirst models.

DropDownList and SelectListItem Array Item Updates in MVC



Ran into an 'interesting' behavior today with a cached list of SelectListItem[] in drop downlist where the cached list was getting updated by MVCs model binder.

Dynamic JSON Parsing in .NET with JsonValue



The JsonValue/JsonObject/JsonArray classes in the System.Json are new for the full .NET framework and recently introduced with the various betas of ASP.NET (and previously WCF) Web API. JsonValue fills the need for dynamically parsing and serializing of JSON at runtime.

.NET 4.5 is an in-place replacement for .NET 4.0



With the betas for .NET 4.5 and Visual Studio 11 and Windows 8 shipping many people will be installing .NET 4.5 and hacking away on it. There are a number of great enhancements that are fairly transparent, bBut it's important to understand what .NET 4.5 actually is in terms of the CLR running on your machine. When .NET 4.5 is installed it effectively replaces .NET 4.0 on the machine. .NET 4.0...

Creating a dynamic, extensible C# Expando Object



In this post I discuss a custom extensible dynamic type implementation that allows you to extend existing types with dynamic properties at runtime.

Dynamic Types and DynamicObject References in C#



This post explains the difference between dynamic reference and explicit references of an IDynamicObject implementation and how they behave differently.

Unable to cast transparent proxy to type <type>



If you've ever run into the Unable to cast Transparent Proxy to error, you know how frustrating it can be. Usually this is caused by multiple assemblies causing unexpected load behaviors. Here's what the problem is and how you can check for problems.

XmlWriter and lower ASCII characters



If you've ever tried to generate an XML document from content that contains lower ASCII characters you might have found out that this will throw exceptions. Here's why this happens and how you can work around the issue in a pinch.

Changing the default HTML Templates to HTML5 in Visual Studio



The default WebForms templates in Visual Studio still use the XHTML doctype headers by default. HTML5 doctype headers are easier to use and read and with HTML5 support now becoming mainstream and backward compatible with older browsers its time to switch those doctype headers. This post demonstrates how to change the default VS templates or create new templates altogether. With HTML becoming more prominent and the new headers being easier to read and smaller in size, it's

Creating a Dynamic DataReader for easier Property Access



Custom dynamic types in .NET are great to wrap other data structures into easier to use and cleaner object.property interfaces. In this post I demonstrate how you can create a dynamic DataReader that allows access to a DataReader's fields using plain object.property syntax.

Creating a Dynamic DataRow for easier DataRow Syntax



The Dynamic Language Runtime features in .NET 4.0 make it very easy to create custom dynamic types that use alternate 'data sources' to expose a new member interface. In this post I describe a simple example that exposes a classic DataRow as a dynamic type to allow cleaner syntax and no need for type casting when accessing DataRow objects.

Dynamically creating a Generic Type at Runtime



How do you get a type reference to a generic type instance for a specific set of generic type parameters at runtime? Generics is primarily a coding time tool that creates code at compile time. It's not real easy to create generic types at runtime using dynamic type information. In this post I talk about an issue I ran into while trying to create dictionary types on the fly.

An easy way to create Side by Side registrationless COM Manifests with Visual Studio



Registrationless COM makes it possible to run COM components without registry configuration making for an xCopy deployable solution. The process is not terribly difficult but not easy to debug if something goes wrong. Here's how you can use registrationless COM in your apps.

An Xml Serializable PropertyBag Dictionary Class for .NET



.NET includes many Dictionary related types but serialization of Dictionaries leaves a lot to be desired. In this post I show how to create a serializable PropertyBag class that makes it easy to XmlSerialize arbitrary key/value pairs into XML and back.

Show raw Text Code from a URL with CodePaste.NET



CodePaste.NET has been around for a while now. But did you know that you can also use it to syntax color code from the Web simply by providing a URL and language? Here's how.

Opening the Internet Settings Dialog and using Windows Default Network Settings via Code



Most applications that need to use HTTP to go online require some sort of HTTP configuration options to allow for custom network configurations. An easy way to do this is to rely on the default connection settings that Windows provides. Here's how to use the Windows network settings and how to bring them up visually for editing programmatically.

COM ByteArray and Dynamic type issues in .NET



Ran into an interesting issue today with binary data passed from COM to .NET via a dynamic instance. The result was rather unexpected with dynamic failing to properly cast the binary to byte[] or even a basic object instance.

Getting the innermost .NET Exception



In some cases when exceptions are thrown, the innermost exception is what holds the most important information. For example, dynamic method calls via Reflection or dynamic invocation. Here's a simple funciont that is useful for easily retrieving the innermost exception.

Web Browser Control – Specifying the IE Version



The Microsoft Web Browser control's default rendering mode is not standards compliant - it's stuck in IE 7 quirks mode even on systems that run a later version of IE such as IE 11. This produces terrible results if you're attempting to use HTML 5 or or CSS 3 markup in your HTML to display. However, the Web Browser control does support using specific versions of Internet Explorer via some registry values that can be set for a specific application. This post shows how to configure your application to work with a specific version of Internet Explorer's rendering engine.

Loading Assemblies off Network Drives



Remote loading of assemblies and CAS policy in .NET have always been hassle and although .NET 4.0 improves security, lightning up rules to be on par with Win32 applications, for COM Interop and custom runtime hosting old rules still apply. Luckily there's some help in the form of a new configuration switch that allows overriding remote loading of assemblies.

HttpWebRequest and Ignoring SSL Certificate Errors



Man I can't believe this. I'm still mucking around with OFX servers and it drives me absolutely crazy how some these servers are just so unbelievably misconfigured. I've recently hit three different 3 major brokerages which fail HTTP validation with bad or corrupt certificates at least according to...

CLR Version issues with CorBindRuntimeEx



I’m working on an older FoxPro application that’s using .NET Interop and this app loads its own copy of the .NET runtime through some of our own tools (wwDotNetBridge). This all works fine and it’s fairly straightforward to load and host the runtime and then make calls against it. I’m writing this up for myself mostly because I’ve been bitten by these issues repeatedly and spend 15 minutes each...

Hosting the Razor Engine for Templating in Non-Web Applications



In this article I describe a set of classes that provide a wrapper around the Razor View Engine so you can use it easily in your own applications to provide templating functionality.

Finding a Relative Path in .NET



Here’s a nice and simple path utility that I’ve needed in a number of applications: I need to find a relative path based on a base path. So if I’m working in a folder called c:\temp\templates\ and I want to find a relative path for c:\temp\templates\subdir\test.txt I want to receive back subdir\test.txt. Or if I pass c:\ I want to get back ..\..\ – in other words always return a non-hardcoded...

The dynamic Type in C# Simplifies COM Member Access from Visual FoxPro



The addition of the new dynamic typing in the .NET runtime greatly simplifies COM Interop when passing FoxPro objects to .NET. Dynamic types remove the need to use explicit Reflection on dynamically generated FoxPro types that are returned over COM interop and so reduce code complexity and produce more natural and readable code removing one of the annoyances in FoxPro and .NET COM Interop.

.NET WebRequest.PreAuthenticate – not quite what it sounds like



On a few occasions I've dealt with Web Services that use - yuk - Basic Authentication and require pre-authentication on the very first request to the server with the server first sending a challenge. This is unusal for HTTP authentication which typically requires a challenge first and then a response with the auth information in the header. The latter approach is what the .NET client components produce by default. PreAuthenticate unfortunately is not quite true to its name and in order to provide true pre-authentication on the first request manual header manipulation is required.

SmtpClient and Locked File Attachments



Ran into an easily overlooked problem a few days ago where SmtpClient messages with attachments would keep the attached files locked on the local machine. Email would send fine with attachments but the local files remain locked after sending. It's easy to miss as the files are locked for writing only so subsequent read operations actually work, but the file is still locked. The solution is easy enough by applying a .Dispose() in the right spot, but nonetheless unexpected.

Generic Types and Inheritance



Although I use Generics extensively, every once in a while it still throws me for a loop when dealing with complex generic parameters and inheritance. In this post I talk about a compilation error I ran into when trying to inherit a generic type including its generic parameters and a way to get around this particular issue.

Simplistic Object Copying in .NET



Copying object data between instances of objects is something that needs to be done quite frequently yet there are few tools that perform this task well. Here is an admittedly simplistic routine that I nevertheless find useful in many situations.

Changing Configuration Settings in a Desktop Client Application



Got a question in response to a Localization article today that asked how to store requested culture settings. In the article I recommend that easiest and most reliable way to switch cultures is to assign the culture when the application runs and allow the user to change cultures somewhere in the UI. When the culture is changed it’s up to the application to decide how to handle the actual culture...

Html and Uri String Encoding without System.Web



Url and Html encoding/decoding is provided on the HttpUtility class in System.Web but in non-Web applications it's not a good idea to force a reference to System.Web into a client project. Here are a few thoughts on alternatives you can use.

Assembly Loading across AppDomains



Every time I need to load .NET assemblies from a non-default path in an application I end up spending quite a bit of time trying to get it right. Today was no different: I had a situation where I needed to create a type in a seperate AppDomain based on a dynamically generated assembly that might live in a directory other than the application’s base path. This is sort of like a perfect storm of...

Monitoring HTTP Output with Fiddler in .NET HTTP Clients and WCF Proxies



Http debugging is immensely useful and Fiddler is a nice tool that provides many options and an easy to use interface to monitor HTTP requests to get maximum information about each request. In order to monitor requests of .NET clients like WebClient, HttpWebRequest or WCF or Web Service proxies you need a little additional configuration to get Fiddler to monitor these requests.

String Extraction



One thing I do quite frequently in applications is parsing strings and a common scenario requires extracting a string from within another string with delimiters. Here's a small utility function out of my StringUtils library that provides this functionality easily.

Calling JavaScript functions in the Web Browser Control



If you're using the Web Browser Control or the Internet.Application Shell object, you might need to call Javacript t code inside the pages loaded in the browser to manipulate the page from say a WinForms app that interacts with the Web Browser control. Some things are just much easier to do with client side script code and being able to initiate this code from .NET can be very useful. This entry describes how you can access the DOM to call script functions both in .NET and FoxPro.

Variable Scoping in Anonymous Delegates in C#



On a few occasions anonymous methods still throw me for a conceptual loop. I'm comfortable with them in JavaScript, but in C# the behavior is a bit foreign and makes for some interesting compiler gymnastics. Anonymous methods work like closures and so variable scoping can be extended into these anonymous methods from the calling method scope which is pretty damn useful and the basis for what makes Lambda expressions work in the first place.

Byte Order Marks and XmlDocument Streaming to HTTP



If you're generating XML content that gets sent out to HTTP you'll need to watch out for the default XmlTextWriter encoding which includes a byte order mark. Including a BOM in Http output effectively produces invalid XML and while a smart XML client will skip over the BOM, others will barf on the BOM and treat it as content.

Dynamic Queries and LINQ Expressions



Using LINQ to SQL in some scenarios where dynamic expresions are required on the right side of a LINQ query expression can be tricky. How do you for example allow a query to use a dynamic field in a query and then query its data? Due to the strong typed nature of LINQ direct LINQ syntax can't be used for this sort of query, but there are a several ways to work around this by using dynamic expressions.

LINQ to SQL ObjectTrackingEnabled and Deferred Loading of Related Data



LINQ to SQL supports object tracking by default, but if running queries it's often more efficient to turn off object tracking. This can be done with ObjectTrackingEnabled, but unfortunately this option has a rather severe side effect on deferred object loading.

.NET 3.5 Framework Distribution Size



One of the considerations of whether to choose .NET 3.5 for your non-server applications might be distribution size. If you're building a vertical application that you're distributing over the Internet you are probably concerned about the size of your installation if you want people to download it. Recent versions of the .NET runtime have a made decidedly nasty turn for the worse when it comes to...

LINQifying - getting rid of CollectionBase?



If you're sitting on some old types that implement CollectionBase you might find that they don't directly work with LINQ. Here's how you can make these types work with LINQ.

Book Review: LINQ in Action



Just got done reading LINQ in Action and it's an excellent read. Rarely do I read books cover to cover, but this book definitely made me want to go through the whole thing as it's full of little gems of information, things I didn't know and lots of new ideas I can hopefully apply soon.

MS Tests failing due to Security Errors



Ran into an odd problem today while testing with a third party DLL. My unit tests failed to run complaining that the third party DLL was not trusted. Turns out the problem is related to the security tags applied to the file when it was downloaded and installed directly of a Web download.

Odd string.Replace Chaining Behavior



I ran into a bit of a head scratcher today with a routine that does some string manipulation. It's an old routine that I use to help me do the equivalent of ResolveUrl() outside of the context of the ASP.NET Page framework - typically in static code somewhere or as part of a handler or other component. The process is easy enough but I ran into a snag with the special case of resolving a root web...

Watch out for XmlDocument.PreserveWhitespace when dealing with Digital Signatures



When creating digital signatures of XML documents its crucial that the Xml document settings on signing match the document settings that are expected for validating signatures. I ran into a problem where our signatures were failing with a vendor's site, due to the PreserveWhitespace property settings on our end and on the vendor's parser being mismatched.

Digitally Signing an XML Document and Verifying the Signature



Signing an XML document and then validating the digital signature of the document doesn't involve a lot of code - once you know how it works, but arriving there is quite the journey. This post describes setting up a certifcate for testing, signing an XML document with the Private key and then validating it with the Public key.

SmtpClient in Medium Trust



SmptClient is supposed to work in Medium trust and it in fact does work, but only if you use Port 25. I ran into an unexpected failure while connecting to my ISP who requires an alternate port for SMTP access outside of their network.

Griping about System.Net.Email.SmptClient/MailMessage



For many years I've been using a home built SMTP client I built using low level Sockets. Single class, set a few properties and it goes off and sends emails. With about 5 lines of code I can be off sending an email from just about any app Web or otherwise. I created the custom class originally to...

Accepting invalid Certificates for WCF/Web Services/HttpWebRequest gets easier



Looks like .NET 3.0/3.5 has updated functionality to allow setting certificate certificate polices. In fact I noticed that the old mechanism I showed in an earlier post has been marked as obsolete, but there's a nicer replacement mechanism available now. I frequently use Certificate policy to...

Detecting Text Encoding for StreamReader



Reading Text files with proper encoding and byte order marks can be a bit of a pain when using a StreamReader as there's no detection of no byte order mark that defaults to UTF-8 which is usually incorrect. Here are a few thoughts on explicitly detecting BOM settings and getting a corresponding Encoding.

A few C# Time Utilities for Fractional Time Values



I found myself working with displaying time values a bit today for a demo app I'm building that needs to display elapsed time values in a meaningful way. There's display, but also storage of total values in a rounded fashion. Here are couple of routines that helped make short work of the time values.

Reflection, GetMember() and COM Objects?



I'm working on an old app that interfaces with a legacy COM object. In reviewing some of my wwDataBinder code I noticed that it didn't work against COM objects for databinding. With a few minor changes I've been able to make the binding code work by using the the higher level Type.InvokeMember...

Back to Basics: .NET Framework 2.0 Book



Every once in a while I feel I need to review the basics of CLR development because frankly I'm not smart enough to keep it all in my head at once and over time the not so frequently used functionality kind of starts getting a little foggy. So from time to time I pick up a core CLR/Language book...

Dynamic Type Invokation in .NET



There many ways to dynamically instantiating types in .NET and while it's not a common task when you need it you might find that there are a lot of different ways that you can instanatiate a type. Here's some discussion of different ways you can do it and a few helper functions to make life a bit easier.

XmlWriter and Schema



In the ResX exporter for my data driven Resource Provider I use a bit of code that iterates over the database resources and then spits out ResX resources from the data as an option to get your resources into your Web site. The code I've used in this stretch of code uses an XmlWriter to quickly spit...

Setting up and running Subversion and Tortoise SVN



Since I've been working with Subversion a bit recently I thought I'd write up a quick step by step guide to getting started with Subversion and Tortoise SVN. Actually this has had a practical side to it - I have a couple of developers on a project that needed to get a quick start and get...

West Wind Html Help Builder Update



I've put out an updated version of Help Builder today. Here are a few development perspective comments on this release. Code Pasting This update adds a handful of new features in regards to handling code in topic content. If you've been following my blog you've probably seen some of the...

Generics and COM Interop don't mix



COM Interop is rarely fun, but it looks like it's getting to be less and less useful as time goes on and new .NET Runtime features come along that don't work well over COM. It appears that Generic types can't be exported over COM and be usable to a client like Visual FoxPro. When I create a class...

Hosting the .NET Runtime in Visual FoxPro



Interop with .NET from FoxPro can be accomplished fairly easily by using COM Interop. With COM Interop you can take advantage of .NET's COM Callable Wrapper to wrap up .NET components and make them available as COM objects. I've written extensively about this interaction (here and here)...

HttpWebRequest and GZip Http Responses



I've talked a bit about GZip compression (here and here and here) on the server recently. It's pretty straight forward to use GZip compression either by letting IIS do it for you automatically or by using some simple ASP.NET code to compress content. As a quick review to create GZip content on...

Hosting a WCF Service in a non-.NET Client



I'm still screwing around Web Connection and trying out a quick proof of concept tonight and thought I'd share a few steps on how to host a WCF in a non .NET client via COM Interop client like Visual FoxPro. This article discusses WCF server and client creation in general terms and in addition covers the interop issues to make it work in these clients.

Source Control and Sharing Projects



Over the years I've been using source control kind off and on for my personal development. I would really love to use source control all the time but in the past I've had a number of issues in making things work correctly with the way I work on my internal projects. For work I do with...

Fumblings and Thoughts on WPF DataBinding



So I spent the evening today experimenting with databinding in WPF. Overall I'm very excited about that data binding capabilities in WPF which finally has produced a powerful and reasonably user friendly way to do data binding of just about any type to anything else. WPF makes this easily available...

DynamicMethod from C# code?



I'm experimenting with DynamicMethod in .NET 2.0 in light of all the good things that apparently have come of it especially in light of the recent release of the Dynamic Language Runtime on CodePlex. I haven't dug into that code (I suspect it won't be light reading <s>), but thought it sure...

Forcing an ASP.NET Application to 'stay alive'



This post in the 'stupid pet tricks' category I suppose - it's not one of the things that you need to do every day, but if you need to run an application that requires that your ASP.NET application stays up and running without the discontinuity of AppDomain or worker process shutdowns this can be...

How many ways to do a String Replace?



You ever pull this stunt? You're in the middle of working and you realize that you need a string function. .NET makes string manipulation fairly easy but it can often be frustrating to find just the right function. The issue is that .NET string functions are scattered over several different objects....

Blocking IIS IP Addresses with ASP.NET



Over the last few months I've had increasing SPAM traffic coming to my site, usually from a few select IP address groups. Most of this site spamming crap that I actually catch tries to simply POST to every possible URL on the site apparently that contains a FORM tag, spewing forth a plethora of...

Overthinking AutoResetEvent in an HttpHandler



I'm an idiot! I spend almost the entire screwing around with some multi-threading code that was locking up on occasion. As everyone knows debugging multi-threaded code - running inside of ASP.NET no less - is no trivial matter to work with and debug. So I'm rebuilding the Web Connection ISAPI...

C# HRESULT comparison



I just had a little brain freeze dealing with HRESULT error from a COMException. When dealing with COM objects you still need to deal with the unfortunate COM idiosyncrasies like HRESULT values which get returned from just about every COM call. COMException exposes this HRESULT as an int value. Now...

WebRequest and SSL Connection Problems



Ever run into a problem with WebRequest or a Web Service Proxy on an SSL request where the first request works just fine but the second one fails? Run again and it works again and then fails again? It's a common problem that occurs when the Keep-Alives aren't handled the way the client requests on the server.

Generics in CodeDom vs. Generics with Reflection



In Help Builder's documentation imports from .NET code I have to manage two sets of interfaces: One that imports data using Reflection which is the more thourough mechanism that goes out, parses types and pulls in XML documentation. Getting Generics to work right in that code took a while to get...

The server committed a protocol violation with WebRequest



I've been working with a host of different OFX financial services to retrieve data from remote servers and merge them into one of my client's systems. These servers are a wide variety of different Web Servers and using various versions of the OFX protocols which has been nothing short of a...

Building a SnagIt Screen Capture Plugin for Live Writer



I spent a few hours a couple of days ago creating a plugin for Windows Live Writer that allows for easy screen captures. I've long been a huge fan of SnagIt from Techsmith and since SnagIt's capture functionality is available as a COM interface it's quite easy to expose the functionality in other...

Evaluating JavaScript code from C#



.NET includes support for JavaScript as a .NET language, but it's not talked about a lot. More interesting though is that you can access the JavaScript runtime from your C#/VB.NET code and it's pretty easy to do although it's not well documented. Here are a few starter scenarios...

Field Value not setting...



I've run into an odd problem that I can't figure out. Maybe I'm just missing something obvious but I have a situation where a field value simply will not set. No error, no failure, but the value assigned simply is ignored.

More on GZip compression with ASP.NET Content



Now that GZip is natively available in .NET 2.0 it's very easy to compress your ASP.NET content with GZip compression.

XmlWriter, Strings and Byte Order Marks



When using an XmlWriter to generate output to anything but files you'll want to be careful of the Byte Order Marks that get generated by default.

Bugged by a Serialization Assembly



I ran into a problem with a type that wouldn't serialize properly because - gulp - of a bad DefaultValue attribute value. It's not a good feelign to have the XmlSerializer fail, but there's a way to actually debug this.

Terminal Server Awareness



Today I needed to differentiate some code that runs a stock windows interface or running under Terminal Services as the UI presented would look horrible and stutter badly under TS. Here's a quick code snippet that demonstrates how to check for Terminal Server and branch if necessary.

Reflection on Problem Assemblies



I ran into a problem today in Help Builder where a bad assembly reference was causing problems with importing type information properly. Here are a few thoughts and a question to see if there are alternatives for type parsing.

Expanding Urls with RegEx in .NET



I frequently need to parse and auto-expand URLs inside of user input. Here's the routine I use to do this.

CLR Data Performance Counter Failures



So I’m revisiting my performance counters that I run on my Web site that provide some rudimentary performance monitoring for my site. It’s useful to keep track of the number of open SQL Connections, number of pooled connections in the CLR pool, StateServer Sessions and a few other things. I’ve...

Rounding down a Date in SQL



Dates in .NET are always represented as DateTime values which include a time portion. Sometimes I need to use dates that are ‘just’ date values and there’s no native mechanism to extract just the date as far as I can see.


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2015