Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
Markdown Monster - The Markdown Editor for Windows

WebLog Posts in Category .NET


Categories
ASP.NET (324) .NET (175) Windows (76) JavaScript (72) jQuery (61) Visual Studio (54) IIS (48) Csharp (47) WPF (47) HTML (46) AJAX (45) ASP.NET (33) Localization (32) LINQ (30) WCF (28) MVC (26) Personal (25) Security (23) HTML5 (23) FoxPro (22) CSS (21) Angular (20) C# (19) Web Services (19) Web Api (16) COM (16) ADO.NET (15) Vista (11) XML (11) Sql Server (10) HTTP (10) IIS7 (10) Markdown (9) WebView (9) Microsoft AJAX (8) IIS7 (7) West Wind Ajax Toolkit (7) Web Connection (7) Entity Framework (6) Internet Explorer (5) Html Help Builder (5) Markdown Monster (5) Mobile (5) Live Writer (5) ASPNET5 (5) C++ (5) OWIN (5) Web (5) SignalR (5) Software Development (5) NuGet (5) WinForms (5) Westwind.Globalization (4) Source Control (4) Silverlight (4) Cordova (4) Conferences (3) DataBinding (3) ASP.NET Core (3) LetsEncrypt (3) Help Builder (3) ISV (3) Networking (3) Office (3) Opinion (3) Razor (3) Web Browser Control (3) WebLog (3) Web Development (2) Visual Studio Code (2) RegEx (2) RSS (2) Speaking (2) Tools (2) Linux (2) Installation (2) Bugs (2) Help (2) Authentication (2) .NET Standard (2) Addins (2) Deployment (2) Dotnet (2) ASP.NET vNext (2) ADO.NET (1) Chocolatey (1) Control Development (1) Credit Card Processing (1) Cross-Platform (1) Dynamic Types (1) Email (1) CSharp Dotnet (1) Desktop (1) AI (1) Security (1) Visual Studio (1) Blazor (1) Blogging (1) ASP.NET Markdown (1) Angular JavaScript (1) FireFox (1) Flexbox (1) Git (1) Graphics (1) Hardware (1) IOS (1) JSON (1) Musings (1) Migration (1) Travel (1) Typescript (1) Testing (1) Threading (1) rxJs (1) SEO (1) RazorPages (1) VS Code (1) Web Assembly (1) Web Deployment Projects (1) Web Design (1) WebSockets (1) WebSurge (1) WebBrowser (1) WebDeploy (1) WFH (1) WPF Windows (1) WSL (1) wwHoverPanel (1) Windows-Terminal (1) Windsurfing (1)

Integrating OpenAI Image Generation into a .NET Application



Image Generation AIs are proving to be very good at creating images that can be used for all sorts of purposes. In this article I discuss how you can integrate image generation right into your own .NET applications using the OpenAI REST API. In addition I'll show how you can integrated this functionality into a larger application and discuss some general thoughts on image AI usage based on some of the experiences from a developer/non-designer user perspective.

Embedding a minimal ASP.NET Web Server into a Desktop Application



Did you ever need to embed a Web Server into a non-Web application? In this post I describe how you can use host ASP.NET in a non-Web application and specifically in a WPF desktop app. What do you need, how is it different and some of the issues that you need to consider if you want to use ASP.NET in your non-Web applications.

Rolling Forward to Major Versions in .NET



.NET Core has sophisticated policies that allows your applications that are compiled to specific versions of the .NET Runtime can roll forward to newer versions. You can specify what part of the version to roll forward and that generally works well, except for preview releases which require an extra step.

Dotnet Tool Component not found on the Mac



I've run into this problem a few times: I install a new Mac OS and then install the .NET SDK. A bit later I install a dotnet tool using `dotnet tool install -g` and then try to run it, only to find out that the SDK is not able find it. This post is a note to self on how to fix the pathing for .NET tools to be found correctly and to be able to run your dotnet tools.

Getting the .NET Desktop Runtime Installed with a Custom Runtime Checker and Installer



I've recently moved my Markdown Monster Desktop Application to .NET 7.0 and I had to make a decision on how to get the Runtime installed or packaged with my application. In this post I review the different deployment modes, the plus's and cons and the solution I ended up with which was to build a custom install wrapper that can check and install the runtime if not already present from an Installer or interactively.,

Getting .NET Library Projects to Output Dependent Assemblies



Recent .NET Core versions have changed how .NET Core Library projects output dependencies into the build folder. The new behavior doesn't output depdencies, unlike full framework .NET projects which always automatically dumped dependencies into the build output folder. This isn't a common requirement, but when you need it, the options are sufficiently obscure and this post discusses how you can make your dependencies output into the build folder

Setting an Absolute Output Path for .NET SDK Projects



By default .NET SDK project dump their final build output into a deeply nested folder structure that describes the build configuration, target, platform and sometimes additional package folders. While that's useful especially for multi-targeted projects. Sometimes you just want your output to go to specific folder without all that noise. In this short post I show you what you need to set in your project file to put your files exactly where you tell them to,

Using Application Insights in .NET Desktop Applications



Using Application Insights with desktop applications isn't the most obvious operation, as App Insights has been primarily designed as a tool for providing logging, statitics and exception report for Web based applications. However, with a little bit of reworking it's actually quite straight forward to use Application Insights with Desktop applications and in this post I show you how I integrate App Insights in my WPF applications.

WkHtmlToPdf: Dealing with broken Url Encoded and Extended Character Links



WkHtmlToPdf is a commonly used tool to create PDF documents from HTML files or Urls. Unfortunately it's a bit cranky and one of the problems you can run into is that links that include URL encoding won't work in your output PDF. In this post I describe the problem and a hacky workaround to make broken PDF links work by hacking the HTML file prior to conversion.

SetResolution: Setting Windows Display Resolution from the Terminal



I recently switched to a single 4k monitor and had a need to quickly switch resolutions to avoid the UI hostile Windows Display Resolution widget in Settings. I ended up creating a small command line utility called SetResolution that lets you quickly and easily set a new Resolution, create profiles of resolutions to switch to.

Referencing a Local Private NuGet Package in your Solution



I recently needed to add a local reference to my project and I couldn't quite figure out the best way to do it in a transparent way to consumers of the repository, so that they wouldn't have to explicitly configure additional build settings in order to find dependencies. In this post I discuss how to add local references or use a local Nuget source to add non-public packages to your projects without explicit package feed configuration.

Async and Async Void Event Handling in WPF



When running WPF and WinForms applications with async operations, I've run into a number of issues with event handling 'hanging' the UI thread in unexpected ways, where the UI hangs until the mouse is moved or a key is pressed. A lot of times these issues are associated with events that fire async code, and in this post I take closer look at one scenario that can cause these hang ups along with a workaround that has proven useful in a number of occasions for me.

West Wind WebSurge 2.0 is here



I've just released West Wind WebSurge 2.0. WebSurge is a REST Client and Load Testing tool for Windows and in this post I provide a short overview, a link to a new YouTube Getting Started video, and some background on this release

Integrating Long Path Names in Windows Applications



Long Path Names in Windows are a pain in the butt, but Windows 10 recently starting adding better support for Long Paths in Version 1607+ which for now has to be enabled explicitly. It also requires an application configuration switch in the manifest file. As nice as that support is, it doesn't solve all problems especially when integrating with other components or external applications that don't support long paths. In this post I describe what works, what doesn't and a few hacks to make most things work.

Connection Failures with Microsoft.Data.SqlClient 4 and later



After a recent update to `Microsoft.Data.SqlClient` version `4.0.0.0` I ended up not being able to connect to any of my SQL Server databases. Turns out Microsoft has made some default settings changes in the updated provider and these settings are likely going to break connections.

Windows Authentication with HttpClient



In this short post I review how to use HttpClient with Windows Authentication security using Negotiate or NTLM authentication schemes, which oddly is not documented in the official documentation for the `CredentialCache` class used to handle authentication header generation in HttpClient.

Back to Basics: Add an ASP.NET Runtime Information Startup Banner



In almost every .NET Core Console application I end up adding a startup banner with some basic runtime information so I can see at a glance what environment I'm running in. I also add the URLs and any other application specific information that might be useful. In this short post I show a few things I display and how I reuse this functionality since it practically goes into every application I run.

Launching Visual Studio Code cleanly from a .NET Application



Visual Studio Code has become the mainstay editor for many developers. If you have developer focused applications and you need to externally display text or code content, it would be very useful to pop open VS Code to display external text/code content. This sounds simple enough, but Code both on Windows and Mac has some peculiar launch behaviors that make this a little more tricky than you might think, especially if you need to make sure that you can do it across platforms.

Using the WebView control to capture HTTP Request Content



Need to capture requests when navigating the new Edge WebView2 control? The control supports this but the way that you do this is a little less obvious than you might be used to from other browser controls. Here's how to do it.

Thoughts on Async/Await Conversion in a Desktop App



I spent the last month or so working through Markdown Monster's code to switch from mostly sync code to async code. This change was forced on me by an Async Cascade triggered by a third party dependency of a component (the WebView2 control) and ended up requiring massive changes throughout the app. In this post I go over some of the issues I ran into converting from sync to async along with some thoughts on the pitfalls.

Running .NET Core Apps on a Framework other than Compiled Version?



I get asked frequently about whether a lower version of .NET Core will run on a machine that only has a more recent version of the .NET Core runtime installed. The short answer is 'No it won't run' but there are a few nuances to this simple answer.

Chromium WebView2 Control and .NET to JavaScript Interop - Part 2



In part 2 of this post series I take a look at how to use the new Chromium WebView2 to interact with the DOM document and interoperate between .NET and JavaScript, both calling into JavaScript from .NET, and calling into .NET from Javascript

Taking the new Chromium WebView2 Control for a Spin in .NET - Part 1



This is Part 1 of a two part article that gives an overview of the new WebView2 Web browser control that is based on Edge Chromium. In Part 1 I look at the basics of what's needed to run the control using the WebView runtime, and how to get the control embedded and configured to use for basic HTML tasks. In Part 2 I look at interaction between the .NET application and WebBrowser and Javascript.

Blank Zero Values in .NET Number Format Strings



Recently needed a way to display a set of numbers in a WPF List display that required that values with a value of `0` display blank - using no explicit code or model changes. I learnt something new today: There's actually a way to use C# format strings to format numbers separately for positive, negative and zero values. Here's how that works.

Watch out for .NET Core Runtime Bitness for IIS Installs



I recently ran into a snag with one of the my Windows Server installs of an upgraded .NET Core 5.0 application. It turns out I didn't install .NET Core 5.0 correctly because I made some bad assumptions of what I needed to install to run my application, even though it previously ran on .NET Core 3.1. Here's more detail on what the failure looks like and how to properly install .NET Core 5.0.

Upgrading several of my Applications and Libraries to .NET 5.0



Over the last week I spent some time upgrading several .NET Core Web applications and libraries from .NET Core 3.1 to .NET 5.0. I'm happy to say that this was always a non-event as the process went very smooth for once. In this post I'll talk about what I found and also offer some commentary why we should celebrate this update and push Microsoft to continue along this path.

Creating Custom .NET Project Types with .NET CLI Project Templates



Custom project templates can be extremely useful in quickly creating new projects especially for extensible applications. They're also great for creating specialized setups to make it quicker to hit the ground running. With the .NET SDK tooling new project templates are now easy to create and this post takes you through the process.

Wrestling with Clipboard Images in WPF



Retrieving images from the clipboard with WPF seems so simple, but once you get into it you'll find that there are lots of problems with reliable image retrieval that works for all images. In this post I talk about the different issues you're likely to run into and one hacky but flexible solution to better image support by selectively sniffing image formats and using different clipboard retrievals based on the image format.

Using .NET Core Tools to Create Reusable and Shareable Tools & Apps



Dotnet Tools offer a simple way to create, publish and consume what are essentially .NET Core applications that can be published and shared using the existing NuGet infrastructure for packaging and distribution. It's y quick and easy to build tools that you can share either publicly or privately. In this article I make a case for why you might use or build a Dotnet Tool and show how create, build, publish and consume Dotnet tools as well as showing some examples of useful tools I've build and published.

A .NET Color Console Helper



In this short post I'll discuss a small Console helper class I've been using to make it easier and more consistent to use colors with the .NET Console command. The .NET Console support colors easily enough, but switching colors and resetting them can be a bit tedious, so these helpers make working with color a bit easier.

ASP.NET Core WebSockets and Application Lifetime Shutdown Events



WebSockets in ASP.NET Core are easy to use but due to the simple model it's easy to forget that socket requests are long lived and can linger for a long time in the background and that can cause problems when an application needs to shut down cleanly. Luckily there's an `IHostApplicationLifetime` interface available that allows hooking shutdown operations and that provides the necessary cancellation tokens to allow an WebSocket connection to be terminated in response to a shutdown event. This post shows how this works.

Using WSL to Launch Several Bash Commands from an Application



Struggled today with launching WSL from a Windows application to automate an external build process. Turns out this was a lot harder than it should have been due to some quirks on how the `wsl.exe` and `bash.exe` are registered by the Windows Sub System for Linux.

Static Constructor Failures and Declaration Order



I ran into an ugly problem today with an application where nested static constructors where not doing the expected thing - failing to provide a value when one should be available. It turns out the issue has to do with constructor calls nesting and the order in which auto-initialized values are assigned.

Displaying Nested Child Objects in the Windows Forms Designer Property Grid



The Windows Forms designer sometimes feels very dumb - one of those times is when dealing with nested properties on a control which by default is not displayed as an expandable property that you can just dig into. Instead you have to do a bit of busy work using a TypeConverter to make it possible to create an expandable property in the designer. Here's how.

Programmatically Opening Windows Terminal in a Specific Folder



The new Windows Terminal provides many cool new features and much improved Terminal performance which makes it very desirable to use even in its current preview state. However, unfortunately the Terminal currently lacks a command line interface to control startup, do if you want to externally launch a shell some workarounds are required to get it to start out of a specific folder.

Visual Studio 2019.2 and .NET 3.0 SDK Projects not Loading



Recent upgrades to Visual Studio 2019.2 seem to have broken projects that use the 3.0 .NET SDK as Visual Studio is defaulting to a pre-3.0 version of the SDK tools and compilers. The end result is that projects even fail to load in Visual Studio. There are workarounds but ultimately this an issue that Microsoft needs to address better in future updates.

Uri.AbsoluteUri and UrlEncoding of Local File Urls



Ran into an interesting problem with the Uri class and local file URLs today. The problem is that Urls were not properly Url encoding and decoding with the Url treated incorrectly. After a bit of experimenting it turns out that the way the file URL is created is critical to the Url parsing behavior of the Uri class.

.NET Core SDK Projects: Controlling Output Folders and Dependencies Output



I've been upgrading Markdown Monster to run on .NET Core 3.0 and one of the biggest changes is switching to the new .NET SDK style format for all projects. I ran into some issues with the Addin projects that require that output is placed in a very specific output folder and to not include output of all references. In this post describe a couple of ways to control where output goes and how to limit the output that goes to those folders.

First Steps in porting Markdown Monster WPF App to .NET Core 3.0



I spent a good part of the day today getting Markdown Monster to run on .NET Core 3.0 and in this post I packaged up my notes into a lengthy post with how went through this process. It wasn't exactly quick to make this happen but MM has a few peculiarities that made this process a little bit more trying than it could have been. I'll summarize some thoughts at the end on both the process and the relevance of this process.

Adventures in .NET Core SDK Installation: Missing SDKs and 32 bit vs 64 bit



Ran into a problem yesterday with a new installation of the .NET Core 3.0 Preview 4 installation. Installed the new preview and found that all of my .NET Core 2.x SDKs were no longer showing. A lot of back and forth later I found that I accidentally installed the wrong bitness SDK - 32 bit vs 64 bit. Here's a quick overview of how and why and why you probably NEVER want to install the 32 bit SDK.

Using .NET Standard with Full Framework .NET



Using .NET Standard on full .NET Framework is a mixed bag because the behavior of .NET Standard differs depending on which version of the Runtime you are integrating with. In this post I review what .NET Standard is and how it fits in with the full .NET Framework and how you can use .NET Standard packages/assemblies in full framework along with some of the problems you have to watch out for.

Finding the ProgramFiles64 Folder in a 32 Bit App



.NET has the `System.GetFolderPath()` method to let you easily retrieve various system folder in a safe way. Unfortunately getting the `Program Files` folder is a bit of problem due to some complications on how the name is retrieved on 32 bit systems. If you're running an application in 32 bit mode, or have an application that can run either 32 or 64 bit, make sure you use the right way to determine where Program Files is located.

COM Object Access and dynamic in .NET Core 2.x



I was surprised to find out that COM Interop works in .NET Core when running on Windows. It's possible to access COM components via Reflection easily enough in .NET Core 2.x. Unfortunately use of the `dynamic` keyword does not work in .NET Core 2.x so for the moment COM interop is limited to using Reflection.

Returning an XML Encoded String in .NET



XML is not as popular as it once was, but there's still a lot of XML based configuration and data floating around today. Today I ran into a recurring issue where I needed to convert a string to a properly encoded XML string. Seems simple enough but it's not as straightforward as you might think to generate an XML Encoded string properly. This post shows a few different ways to retrieve a string and discusses advantages of each.

Creating a .NET Global Tool from an existing Console Application



.NET Core doesn't support creating executables directly, but it does have support for **Global Tools** which provide a mechanism to register a console application and make it easily accessible using a simple command line command rather than a complex `dotnet.exe` command.

Creating an HTML Packager



Recently I needed to add the ability to save HTML documents in Markdown Monster. Saving raw rendered Markdown is not really sufficient and so I set out to create an HTML packager that can package an HTML Web endpoint into a self-contained local package either as a single self-contained file, or an HTML document with all dependencies localized. In this post I discuss why this is needed and how to implement and use this library to capture HTML output in a few different ways.

Explicitly Ignoring Exceptions in C#



In most applications I have a few places where I explicitly need to ignore errors. While generally this isn't a good idea, under some circumstances you just don't care if an error occurs or you simply want a yay or nay response. In this stupid pet tricks post, I describe a few scenarios where not catching any exceptions makes sense along with a couple of helper methods that make these scenarios more explicit so code analyzer and book thrower reviewers can be quieted down.

Which .NET Core Runtime Download do you need?



.NET Core has a number of different runtime downloads that you can grab to install. The combinations of downloads can be a bit confusing and it depends on whether you install a development or runtime environment. In this post I describe what each download contains and what you should use it for.

Getting the .NET Core Runtime Version in a Running Application



Microsoft has a long history of not providing a reasonable way of looking up the version of the runtime that is hosting your applications. .NET Core is no different and in this short post I show one way you can capture a descriptive name of the runtime executing that's suitable for displaying in your application's info page.

Accessing Configuration in .NET Core Test Projects



.NET Core provides a clean configuration system and in ASP.NET Core that code is automatically configured for you. In test and other non-Web projects however you have to manually configure the configuration provider yourself. In this post I look at a couple of ways to set up a configuration provider both using raw configuration objects or by explicitly configuring through the depedency injection system.

Distributing Content and Showing a ReadMe file in a .NET Core Nuget Package



.NET SDK style projects no longer support packaging NuGet content into projects as older projects did. So if you need to ship some dependent content with your library you need to find a different way to do so. In this post I look at a specific example of library that requires additional content and look at how to distribute the extra content as well as displaying a readme file to link to instructions when the NuGet package installs

Easy Configuration Binding in ASP.NET Core - revisited



In this post I'm taking another look at using strongly typed configuration settings in ASP.NET Core, using a slightly simpler approach that foregoes using IOptions in favor of directly using a configuration object instance. In the process I review the various approaches as a summary for getting configuration settings into .NET types.

.NET Core 2.0 and ASP.NET Core 2.0 are Here



After a long wait .NET Core and ASP.NET Core 2.0 are finally here. This release is a major update from Version 1.0 that brings back a ton of functionality that was originally missing in .NET Core 1.x. With closer compatibility to full framework .NET it's much easier to port existing code to .NET Core, as having a much larger API surface to use in your applications. There are many usability improvements that make it easier to get started using considerable less fanfare. In this post I describe some of what's new and what's great and also a few things that are not so great.

Conditional TargetFrameworks for Multi-Targeted .NET SDK Projects on Cross-Platform Builds



If you build multi-targeted .NET SDK projects on multiple platforms you're going to find out that certain targets can't be build on certain platforms. If you target NetStandard and Net45 on a Mac, Net45 is going to fail. In order to get around this you need to conditionally build per platform. Here's how.

Multi-Targeting and Porting a .NET Library to .NET Core 2.0



I've been holding off porting any of my full frameworks to .NET Core. With the latest .NET Core 2.0 and .NET Standard 2.0 releases and their vastly larger footprints that match more closely with what we expect of the .NET Framework feature set, migrating looks a lot more appealing. In this post I describe the process of porting one of my general purpose full framework libraries to .NET Standard 2.0 and in the process also creating a multi-targeted project that compiles .NET 4.5, 4.0 and .NET Standard projects.

Upgrading to .NET Core 2.0 Preview



With the release of the first preview of .NET Core 2 and ASP.NET Core 2.0 I decided to upgrade my AlbumViewer sample application to the latest bits and preview tools. Overall the experience was pretty smooth, but I ran into a couple of breaking changes and a few tooling snags that I'll describe in this post.

Creating a Markdown Monster Addin: Save Images to Azure Blob Storage



The Markdown Monster Markdown Editor and Weblog Publishing tool has a .NET based addin model that makes it relatively easy to extend its core feature set with custom functionality. In this post I show how you can quickly create an addin of your own, and then show a practical example that demonstrates how add Image uploading to Azure Blob storage as an interactive addin.

Faking out the .NET Runtime Version



I've been struggling with DPI Scaling issues in WPF in Markdown Monster and .NET 4.6.2 has a few fixes that address the problems I've been working on. However, requiring 4.6.2 is a problem due to lowish adoption rates and skittishness about installing new versions of .NET. In this post I show a little hack that allows me to compile my app to .NET 4.6.2 but don't require user to have that version installed so those that have it can take advantage of the updates.

Back to Basics: String Interpolation in C#



String Interpolation provides string templating for string literals in C#. Rather than using string.Format you can use string interpolation to produce much more readable code that embeds expression values directly into string literals rather than escaping numeric arguments as you do with string.Format(). In this post I look at how string interpolation works, what the compiler does under the covers and some common use cases where it makes life easier.

Downgrading a .NET Applications from 64 bit to 32 bit for the WebBrowser Control



Recently while working on Markdown Monster I ran into some odd crashes and behaviors when interacting with the Web Browser control in this WPF application. It turns out that some of these inconsistent behaviors are apparently caused by running hte application in 64 bit mode. Switching to 32 bit mode has made the application and Web Browser interaction much more responsive and has stopped the nagging unexplainable crashes. In this post I look at 32 and 64 bit applications in .NET and outline some of the issues I ran into and how I fixed the problem by switching to building a 32 bit app.

Visual Studio Debugging and 64 Bit .NET Applications



Recently while debugging a 64 bit application I found out the hard way that Visual Studio by default will use 32 bit debugging even when running what would otherwise be a 64 bit .NET application. There are a number of options that determine the bitness of your application, but the debugger often behaves differently than your standalone application. In this post I describe, why this might be a problem in some situations and how you can get the debugger to run in 64 bit.

WPF Rendering DUCE.Channel Crashes due to Image Loading



I ran into a nasty WPF rendering bug that affected only a few select machines. Rendering problems in WPF can be terribly difificult to debug because there often is no additional information on what failed and the exceptions that occur are not trappable but fall back to application wide error handling. In this post I describe a specific failure caused by a 'bad' image WPF can't deal with and how I tracked it down and fixed it.

Loading .NET Assemblies out of Seperate Folders



In the process of updating the Addin manager in Markdown Monster I ran into a few snags with loading .NET assemblies out of separate folders. Assembly loading out of non base folders in .NET can be problematic and sure enough I ran into a few issues that took a while to find a work around for. In this post I describe some of the issues of folder based assembly loading and a brute force solution to deal with assembly resolution.

.NET Standard 2.0 - Making Sense of .NET Again



It's taken awhile but it seems Microsoft is finally nailing the message for .NET going forward and .NET Standard with its common API specification is a huge part in making sure that the same base library of .NET is available on all .NET platforms. In this post I look at what .NET Standard is, how it works and what some of the surrounding issues and impacts are for the .NET Eco system.

Capturing Zoom Operations in the WPF Web Browser Control



If you need to capture Zoom operations in the Web Browser control - either to avoid letting hte user zoom or to capture the zoom operation and take action on it - you need to dig into the Web Browser's DOM events to capture the scroll wheel and key events. In this post I describe how you can do just that by looking at an application that captures scrolling and rather than zooming adjusts the font size of the content.

Using Westwind.Globalization to edit loose RESX Files



Although Westwind.Globalization is primarily aimed at Web applications, you can also use it to edit arbitrary RESX files using the Localization Administration interface that comes with the library. In this post I show how you can import RESX resources, then use the editor to manipulate RESX resources interactively, and then export the resources back out, using a local Web application on your machine.

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.

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.

No more Meta Refresh Tags



Eh, I've realized that there's actually an easier way to get a page to refresh with HTTP headers rather than using a Meta tag.
West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024