My Instagram feed

My Instagram feed

2017-01-13

Free Code Improvement Alternatives

I really liked using ReSharper (JetBrains) in Microsoft Visual Studio.

There are also some other commercial tools like it:
- CodeRush (DevExpress)
- JustCode (Telerik)

The functionality that I found most useful was:
- Go To Implementation
- Find Usages
- Suggestions on code improvements

I think that ReSharper has become too expensive now, currently at a $299 first year subscription, then a bit lower on subsequent years. That's about 40% of the price of Visual Studio Professional, and you don't even buy the product - you subscribe.

So I am testing out this combo as an alternative:

Several very handy tools:
- Productivity Power Tools

For code improvement suggestions (pick one, not both):
- CodeCracker for C# (testing this now, looks good)
- Refactoring Essentials for Visual Studio*

I have also tested CodeMaid, but now just right now*.
I may enable it again at a later point in time.
It looks like a very useful addition to Visual Studio.

Here are some related Stack Overflow questions:
http://stackoverflow.com/questions/2834439/what-are-some-alternatives-to-resharper
http://stackoverflow.com/questions/24542406/alternatives-to-resharper

*Enabling too many competing plugins may cause VS to run very slowly.

2016-08-05

Appear to browse from a different country

If you want to test what your website looks like for people in a different country, you might like to try this:

http://teleport.to/

Use at your own discretion.

2016-06-02

CS1056: Unexpected character '$'

When you get the message " CS1056: Unexpected character '$' " in runtime asp.net, it means that the front end file (html/aspx) is using a way of formatting strings which is called "string interpolation".
But to use string interpolation in your web frontend files you must put the following into your web.config file:

<system.codedom>
  <compilers>
    <compiler language="c#;cs;csharp" extension=".cs"
      type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
      type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
  </compilers>
</system.codedom>

Source:
http://stackoverflow.com/questions/30832659/string-interpolation-in-a-razor-view
 
Disclaimer:
The above worked for me, but may not work for all .NET Framework versions and/or ASP.NET versions.

2016-03-02

Catching mails

When developing a solution, sometimes it is nice to be able to catch mails and store them somewhere in stead of potentially sending them to real customers.

In web.config or app.config, there is a setting that can accomplish that for you:

<system.net>
  <mailSettings>
    <smtp deliveryMethod="SpecifiedPickupDirectory">
      <specifiedPickupDirectory pickupDirectoryLocation="c:\Temp\Mail"/>
    </smtp>
  </mailSettings>
</system.net>
 If you install an eml-viewer or maybe just a regular mail client, you can open and read the mails from the folder you specified.

Source:
http://stackoverflow.com/questions/567765/how-can-i-save-an-email-instead-of-sending-when-using-smtpclient

2016-02-16

Fiddler on Windows 10

I've previously written about Fiddler here:
http://stgaup.blogspot.no/2013/03/fiddler-tricks.html

When installing Windows 10, you create an account which is not connected to any external host in any way. Later however, you probably associate your account/Windows 10 instance with your Microsoft account. Afterwards you will use your Microsoft account when logging in.

In my previous post I mentioned one could make Fiddler work by running the app pool on the same account at that on which Fiddler is running (and which you are most likely logged on to).

But there are now two accounts it seems:
  • the one you created while installing, 
  • and the Microsoft account,  
so which one should you use when running Fiddler?
Turns out it works with the Microsoft account.

Username: someone@hotmail.com/outlook.com/live.com etc.
Password: the password associated with the Microsoft account.

2016-02-12

DLL-hell: log4net... oldKey vs newKey

Since log4net now comes in 2 flavours, namely oldkey and newkey, since the Development team decided to change the key, this may cause some trouble.

Here's my solution:

1) Update your Project by getting the latest version from nuget (currently 1.2.15.0) by using update (or other). This should get you the "newkey" version, which has publicKeyToken="669e0ddf0bb1aa2a". You can also download it from Apache.

2) Go to Apache and download the oldkey version (publicKeyToken="1b44e1d426115821"), and place it somewhere nice on your DEV PC.

3) Open a Developer Command Prompt for your version of Visual Studio, and run the GACUTIL utility to install the oldKey dll into the Global Assembly Cache (GAC).

4) Update the Runtime/assemblyBinding section of your config file (web.config  or App.config) With the following:

<dependentAssembly>       
  <bindingRedirect oldVersion="0.0.0.0-1.2.15.0" newVersion="1.2.15.0" />       
  <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />     
</dependentAssembly>     

<dependentAssembly>
  <bindingRedirect oldVersion="1.0.0.0-1.2.15.0" newVersion="1.2.15.0" />
  <assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" culture="neutral" />
</dependentAssembly>

Hope this helps!

The .NET SDK 4.0 or 4.5 tools could not be found.

First, my situation was that I had a brand new laptop which I had installed Windows 10 on. Next I installed Visual Studio 2015 Community Edition, full install (including support for F#).


So when I tried to compile my F# projects, I got this error:

The type provider 'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders' reported an error: The .NET SDK 4.0 or 4.5 tools could not be found.

So I found these resources:

The third one seems to be the one to read, it has several suggestions. I tried to do several of them, but what fixed it in the end for me was the suggestion in the very last post:
  • Install Windows 8 SDK.

I first had a problem installing it, it rolled back while installing, so what I think worked was to just check "Windows SDK" and ".NET 4.5 SDK" in the list of components, leaving the rest unchecked. I also tried to re-register the vbscript dll as per this post (which you may also try if it won't install):
  • http://stackoverflow.com/questions/19251176/error-code-2753-during-install

I also ran the script that was mentioned in the forum, just mentioning in case it may have been a part of the solution.


I also restarted my PC quite a few times.


 So what didn't work (or did not seem to):
  • Install Windows 8.1 SDK
  • Install Windows 10 SDK

2015-01-22

Fun with programming

Have a go at these puzzles:
https://www.codehunt.com/
http://www.pexforfun.com/

Here’s a fun programming language that even (or especially) kids may try:
https://blockly-games.appspot.com/

Here’s another called Scratch:
http://scratch.mit.edu/

Resources for teaching kids to code:
http://www.teachkidstoprogram.com/