New RPN Calculator for Windows

by fwhagen Tue, 18 December 2018

I couldn't (easily) find a decent and simple RPN calculator online anywhere, so I am making my own.  As I get closer to it being more functional, I will post it here for anyone to use.  It will be completely free for anyone to use, reverse engineer, copy, whatever they want.  I miss my old HP-15C, but carrying a physical calculator is just not practical anymore, and the one in windows is not RPN.



Requires .NET 4.6.1 or higher.  Eventually will update it to .NET Core once WPF is finalized in that framework.  The grayed keys are not yet implemented.  For 64-bit Windows, of course (I'm not supporting 32-bit anymore).


Filed Under: .NET | PowerTools | Programming | Software

Deploying Old MVC3 WebApps to Old 2008R2 WebServers

by fwhagen Wed, 04 October 2017

I just spent way too much time moving an Intranet webapp from one server to another for a client.  The publish was easy enough, and everything worked on the server, but I could not access it from a remote workstation.  It uses Windows Authentication for security and customized views, but I kept getting the annoying "401.1 - Unauthorized: Access is denied due to invalid credentials" error from IIS.  I tried a bunch of things, many very weird from the Internet.  Then happened on the following post from StackExchange:

How can I check if my IIS site is using NTLM or Kerberos?


I simply flipped NTLM to the top of the Providers list, and it worked perfectly.  (Ger there by dbl-clicking the Authentication icon in IIS Manager for the site.)

I should probably do that for the Default Web Site (top) layer for all my servers.  Make my life easier, until I forget again.  I should probably post that.....



Filed Under: .NET | System | Work

Sharing NuGet Packages Across Projects

by fwhagen Wed, 04 January 2017

Frequently, when developing multiple apps with a shared set of libraries, NuGet package sets can get out of hand. There’s no need for each project or solution to have it’s own set of libraries, and they should definitely not be in the repository.  I found this solution the other day to be most satisfying:

Create a file called nuget.config and place it in a common root directory for all the projects and solutions you want to share it.  Then fill it with the following:

    <add key="repositoryPath" value=".\Libraries\packages" />

Of course, you can use any value you wish.  I like to keep applications in subdirectories of .\Applications and shared libs in .\Libraries, but that’s me.  the way this works, according to NuGet docs, is the package handler searches for this file locally, then recursively up the folder structure from the project calling it, then a global file in your %appdata% directory.  When the file is absent, it defaults to the familiar behavior of creating the packages subdir in the solutions directory.

This gem has helped me a great deal.  Hopefully you too.


Filed Under: .NET | Programming

Appending a String to All Strings in a List<String>

by fwhagen Wed, 13 June 2012

This is one of those great 1 liners in C# that I can never remember how to do.  If you want to add a value to every string in a List<String>, you can use LINQ to easily utilize String.Format() (or String.Concat()) to do so.  Given a List<String> paths:

paths = (from p in paths select String.Format(@"{0}\badfiles\", p)).ToList<String>();


Filed Under: .NET

Software Versioning Rules

by fwhagen Wed, 07 March 2012

Find a versioning method and stick to it!  I have been looking for a good set of rules to apply to all versioning exercises and I have finally found one called Semantic Versioning, or SemVer, online.  And as a bonus, it follows my preference in versioning pretty closely too.  While I normally use or depending on scope, SemVer prescribes following convention:

  • Major: Breaking changes.
  • Minor: New features, but backwards compatible.
  • Patch: Backwards compatible bug fixes only.

Good rules to code by.  And since I like to include the build number as the last digits, automation through the fantastic Build Version Increment VS plugin, makes it (almost) easy.  (Configuration can be a challenge on larger projects.)  Dig a little to find the latest version that also supports VS2010.

Keywords: , ,

Filed Under: .NET | Programming | Software

Simple C# Command-Line Compiles

by fwhagen Tue, 29 September 2009

In the category of “So I don’t forget again”, here is how to compile a simple code.cs file to a console executable:

csc /t:exe NetDir.cs

Very simple, very easy.  To make it a Windows exe (console app with no console window, very useful for scheduled or batch processing), change the target (/t == /target) to winexe.


Filed Under: .NET

Converting Large (Random) Numbers to AlphaNumeric Strings

by fwhagen Thu, 07 May 2009

I have a need to take large random numbers (on the order of 20 digits) and encode them to easily typable strings.  I created a quick method to do this in C#.  This is the code:

private string ConvertToBase(ulong id)
    // Seed replacement characters for baseX values
    string NumericBaseData = "0123456789ABCDEFGHJKMNPRSTUVWXYZ"; // this string may be in any order as long as each char used only once
    ulong OutputBase = Convert.ToUInt64(NumericBaseData.Length); // baseX determined by number of unique chars in seed string
    string OutputValue = "";
    ulong In = id;
    while (In > 0)
        ulong tn = In % OutputBase;
        OutputValue = string.Concat(NumericBaseData.Substring(Convert.ToInt32(tn), 1), OutputValue);
        In = In - tn;
        In = (In / OutputBase);
    return OutputValue;
For simplicity, I used unsigned longs (64bit), since I am dealing with really big numbers.  Performance is reasonable, I am able to generate a large System.Random, mod it against an arbitrary number of DateTime.Now.Ticks, datestamp it, and convert it using the method above in under 9 ms each.  (I also have an algorithm to test for uniqueness against previously generated values, but the timings grow with greater sample size as expected.)  This method can be modified with any number of cipher characters as long as they are only used once.  This particular one uses all letters and numbers except 'O', 'Q', 'L', and 'I' to avoid confusion to end users and is URL freindly.

Keywords: ,

Filed Under: .NET | Programming

Does This String Have Anything In It? in C#

by fwhagen Wed, 04 March 2009

The following code should be failed by the C#.NET compiler:

if (eventName != null && eventName.Length > 0)

It should never be used.  People, always use this instead:

if (!String.IsNullOrEmpty(eventName))

It is much more compact, clearer, singleton, and as a String class method, more efficient.

So stop it!  You will thank me later.  Not to mention:  Where are your parentheses?  Block your code.  Other people have to read it too!

That is all.

Keywords: , ,

Filed Under: .NET | Programming | Rant

C# Business Objects and CSLA.NET

by fwhagen Thu, 11 December 2008

I am learning and working with a Business Objects framework at work called CSLA.NET (Component-based Scalable, Logical Architecture).  It is built heavily using the best of OOP especially polymorphism and abstraction.  You build your objects all based on a handful of base classes that provide a huge variability of useful features.  It also abstracts out data and .NET remoting layers to make the developers life easier.  If you are building large, scalable n-tier applications, you should definitely look this one up. 

Also check out the book Expert C# 2005 Business Objects, which is the companion to the framework.  If nothing else, it contains a great description of n-tier architecture and why to use it.


Filed Under: .NET

Subversion for Visual Studio Users

by fwhagen Tue, 14 October 2008

VisualStudioLogo subversion_logo-200x173 There are a few articles online covering SVN and VS, but many are out of date and a bit more complicated than necessary with advances in both products.  For a current install (Oct 2008:  SVN 1.5.2 / VS2005), you only need 3 files:

Subversion is, of course, the Source Control server itself.  The MSI install contains everything needed to run on a Windows server.

TortoiseSVN is a plug-in for Explorer that gives a great deal of control to the source repository using the right-click context menu.  Check-ins, updates, merges, etc. can be done through this interface as well as full repository browsing and maintenance.

AnkhSVN is the most important tool for the .NET developer.  It integrates the controls needed for team development directly in the environment.  Much like the integration offered through VSS, but much better.

Installation of Subversion itself is very easy.  Just run the installer.  I installed into C:\SVN\ instead of the default "Program Files" directory, but I am lazy and hate spaces in filename on the command-line.
NOTE:  The installer only puts the files in place and sets the important environment variables.
Once installed, the following command is used to setup a repository:

svnadmin create "D:\SVN\Repository"
You can create as many repositories as needed, but one for now.  Before we activate the server, two config files need to be edited.  They were created with the repository above.  They are svnserve.conf and passwd in the conf sub-dir of the repository.  Uncomment the following:
anon-access = read
auth-access = write
password-db = passwd

harry = harryssecret
sally = sallyssecret

Now the installation can be tested. Execute the following command in a command window:

svnserve --daemon --root "D:\SVN\Repository"

To create a project, execute:

svn mkdir snv://localhost/newproject

Now would be a good time to install TortoiseSVN if it hasn't been yet.  Connect to the running server from within an explorer window by right-clicking and selecting TortoiseSVN > Repo-Browser.  Enter the name of the server to see the interface using the following URL:  svn://servername/  The project "newproject" should be viewable there.

And now the most difficult part of all:  Installing SVN as a service in windows.  The following command will accomplish this.  Syntax and proper spacing is critical.  (I was having problems until I realized the space after each '=' in the command.)  Here it is:

sc create SVN_CSTeam binpath= "c:\svn\bin\svnserve.exe --service --root D:\SVN\Repository" 
displayname= "Subversion Repository for CSharp.NET Team" depend= iisadmin

And that is why I do not use the default paths.  Spaces have to be delimited with quotes, which have to be escaped, and it just is not worth it.  All on one line of course.  Also note that the name after the "create" parameter can be anything desired and allows for multiple repositories on the same server, along with unique displayname.  I chose to use iisadmin as a depend, not because it necessarily is, but because it is sure to load other depends such as Tcpip and such.

The last step is to load AnkhSVN; a solution I leave to the reader.  It's not hard.  If you are familiar with source control at all, it is pretty obvious.

I'd like to thank the following sites for very useful information in helping me through the installation and the creating of this post:

Keywords: ,

Filed Under: .NET | Programming