Archive for the ‘Development’ Category

AnkhSVN “No uncommitted changes” but nothing is shown in the log and update does not solve the warning

Tuesday, January 14th, 2014

When doing a merge using AnkhSVN and doing “pre-merge best practices check” the error message “No uncommitted changes” is shown this means that the working copy is not updated or has changes that are not commited.

However sometimes this error can be shown even when the pending changes window in Visual Studio is empty and you have done update to Latest version. (Most likely there are files that Subversion see as missing or Deleted but that are not shown in the pending changes window)

The solution I use when this happens is to open the working copy folder and use TortoiseSVN to see what is going on and then solve things so that TortoiseSVN shows nothing in the pending changes.

Also from the console “svn status -q” can be used to see what files have changes. (-q means that we only would like status on files that are under version control.

Internet Explorer 10 Turning Compatibility mode on (From server)

Wednesday, November 6th, 2013

In order to turn Compatibility mode on for Internet Explorer the server should send “X-UA-Compatible” as a header with the value IE=EmulateIE9. This will force Internet explorer to use compatibility mode if it is a version higher than 9

If we using ISS (making for instance a asp.net project) the following web.config can be used to do this.

<configuration>
  <!-- Other settings -->
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <clear />
        <add name="X-UA-Compatible" value="IE=EmulateIE9" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

Mode details on the possible values for the header tag

Sometimes sending this as a header tag works, then this should be sent first in the header tag

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />

Internet Explorer 10 Turning Compatibility mode off (From server)

Wednesday, November 6th, 2013

In order to turn Compatibility mode off for Internet Explorer the server should send “X-UA-Compatible” as a header with the value IE=Edge. This will force Internet explorer to use the latest mode the version has (this works from IE 6 to 11 and up)

If we using ISS (making for instance a asp.net project) the following web.config can be used to do this.

<configuration>
  <!-- Other settings -->
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <clear />
        <add name="X-UA-Compatible" value="IE=Edge" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

Mode details on the possible values for the header tag

Converting a Integer? to a Integer (converting a Nullable(Of Type) To a Type)

Monday, September 30th, 2013

In order to convert a nullable Integer to a Interger, all that needs to be done is to call the GetValueOrDefault function of the nullable Type.

Dim intNullable As Integer? = Nothing
Dim int As Integer = intNullable.GetValueOrDefault()

Converting a Integer to a Integer? (converting a Type to a Nullable(Of Type)

Monday, September 30th, 2013

In order to convert a Integer to a nullable interger, all that needs to be done is to call CType

Dim int As Integer = 0
Dim intNullable As Integer? = CType(int, Integer?)

Git replacing the editor for commit messages

Thursday, February 14th, 2013

The man page says

ENVIRONMENT AND CONFIGURATION VARIABLES
 
The editor used to edit the commit log message will be chosen from the GIT_EDITOR environment variable, the core.editor configuration variable, the VISUAL environment variable, or the EDITOR environment variable (in that order).

So in order to make nano our default editor we can do

git config --global core.editor "nano"

--global means this will become a default setting for all of git (leaving it out would only affect the current git repo you are running the command from)

Visual Studio 2012 and Razor 1.0 (opening an older project in 2012)

Monday, December 17th, 2012

VisualStudio 2012 assumes we are using the latest and greatest (version 2) when it comes to the Razer view engine. However when we are opening a project that was created using version 2010 then we were using 1.0 and that is the reason that 2012 is telling us about all the errors it believes we have with our project.

The solution is to edit the web.config file and under “appSettings” tell VisualStudio that this project is using version 1.0

<add key="webpages:Version" value="1.0" />

vb.NET inserting a file to a Binary field in the Database

Friday, December 14th, 2012

In order to store Binary data in a table, all that is needed is to upload the bytes from the file, one way to do this is to use File.ReadAllBytes

Dim fileName As String = "C:\testfile.txt"
 
dbCommand = New SqlCommand("UPDATE FileTable SET BinaryFile=@BinaryFile WHERE FileId = @FileId", dbConnection)
dbCommand.Parameters.AddWithValue("@BinaryFile", File.ReadAllBytes(Filnamn))
dbCommand.Parameters.AddWithValue("@FileId", FileId)
 
dbCommand.ExecuteNonQuery()

.NET what path is the application running from?

Wednesday, December 12th, 2012

In order to get the Directory the application is running from we can use the AppDomain.CurrentDomain.BaseDirectory property

Dim runningFrom As String = AppDomain.CurrentDomain.BaseDirectory

.NET and matching element name with wildcard using XPath

Friday, December 7th, 2012

This is similar to matching a name space with a wildcard.

'This is the node we are searching in
Dim someXmlNode As XmlNode = FetchXmlNode() 
Dim xPathExpr As String = String.Empty
 
'find all nodes with names that starts with nisse_
xPathExpr = ".//*[starts-with(name(), 'nisse_')]"
 
'loop through all elements that matches our XPath
For Each elementWithNisse As XmlNode In someXmlNode.SelectNodes(xPathExpr)
 
    AndHereAMiracleHappens(elementWithNisse)
 
Next