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