Archive for the ‘.Net’ Category

Add the following lines in the migration code:

if (!System.Diagnostics.Debugger.IsAttached)

This launches and instance where you can debug inside an Entity Framework migration method.

Read Full Post »

There are several ways to remove unwanted characters from a string, here is one quite nice…

char[] unAllowedCharacters = “/\\.,;:+*’§½\”<>|!?$&=@#%{}^~[]`´¨¤”.ToCharArray();

text = String.Join(“”, text.Split(unAllowedCharacters));

Read Full Post »

Today I’m working in a project which previously has exclusive checkout right set to on. I changed this today, as I think that it’s generally not a good idea to have it like this (only one user can checkout a file a time).

However, I still got the error message “No items were checked out – The item is locked for check-out by”… error message in Visual Studio, I guess this is because the file was checked out prior to the exclusive checkout change. To fix this, I had to run the following command in a Visual Studio command prompt:

tf undo /workspace:<workspace name>;<user name> $”<path to file>”

Replace the values between <> with the appropriate values). The workspace name/user name and path was found in the output windows in Visual studio:

No items were checked out
The item $/THEPROJ/DEV-Branch/client/src/Client/frmMainMDI.cs is locked for check-out by donald.duck in workspace LATEST_REAL.

For the values above, this shoud be:

tf undo /workspace:LATEST_REAL;donald.duck $”/THEPROJ/DEV-Branch/client/src/Client/frmMainMDI.cs “

Read Full Post »

Another Regexp tester site…

This site is very handy if you want to write and test regular expressions: http://www.regexr.com/. A quick reference is also handy to have opened if you don’t have all rules in your head (I don’t): https://msdn.microsoft.com/en-us/library/az24scfc%28v=vs.110%29.aspx.

Read Full Post »

Simply run the command (it’s part of the Team Foundation Power Tools), this also makes it possible to do a undo checkout on  them:

tfpt uu . /noget /recursive

Read Full Post »

I successfully followed the official release notes for MVC4 which describes how to upgrade a MVC3 project to MVC4. I did the same, but upgraded a MVC2 project.

See here what should be done:

Read Full Post »

Merging of code could be a bit of pane in the ass sometimes, however when you only made changes to a number of files it might be easier to go trough a list of changed file and merge each of tem one by one.

You can get such as list by doing the following:

– Go to the ‘Source Control Explorer’
– Right-click on the folder you want to compare, and choose compare.
– Change the source version type to ‘Date’ and specify the start-date
– Change the target path to point to the same folder as the source path (i.e. the server-path)
– Change the target version type to Date and specify the end-date (or just leave it blank if you want to see all changed files up to todays date)

Read Full Post »

This is something I’ve done recently, i.e. to create IIS applications via Powershell scripting.

# Run this powerscript as an administrator (needed for IIS stuff)

# Create folders for the web site

$drive = “c:\”

“Creating folders…”

# home folder
$myhome = $drive + “mysite\”
new-item $myhome -itemtype directory

# log folders
new-item ($myhome + “Log”) -itemtype directory
new-item ($myhome + “Log\WebLog”) -itemtype directory

# web folders
new-item ($myhome + “www”) -itemtype directory
new-item ($myhome + “www\client”) -itemtype directory

# IIS stuff

# Load IIS module, to be able to do IIS stuff
import-module webadministration

# Set webadministration as default for all commands

# Creating app pool, with some properties
$appPoolName = “myAppPool”
new-item (“AppPools\” + $appPoolName)
Set-ItemProperty (“AppPools\” + $appPoolName) -Name recycling.periodicRestart.requests -Value 1000
Set-ItemProperty (“AppPools\” + $appPoolName) managedRuntimeVersion v4.0
Set-ItemProperty (“AppPools\” + $appPoolName) enable32BitAppOnWin64 “true”

# Create the webapp & site
$homedir = $drive + “mysite\www\”
$hostname = “www.myhostname.com”
$sitename = “MySiteName”
$appname = “www.myhostname.com”
New-Item (“\Sites\” + $sitename) -bindings @{protocol=”http”;bindingInformation=(“:80:” + $hostname)} -physicalPath $homedir
Set-ItemProperty (“\sites\” + $sitename) -name applicationPool -value $appPoolName
New-Item (“\Sites\” + $sitename + “\client”) -type Application -physicalPath ($homedir + “client”) -force

# Change Logging
Set-ItemProperty (“\Sites\” + $sitename) -name logFile.directory -value ($drive + $sitename + “\Log\WebLog”)


Read Full Post »

I got this tip from a friend, i.e. to disable ping in the identity pool to avoid timeouts during debugging of web applications: http://www.shubho.net/2011/02/debugging-timeout-visual-studio-iis7.html. Thanks a lot Per!

Read Full Post »

So, where’s a ClickOnce app installed?

Win XP:
C:\Documents and Settings\\Local Settings\Apps\2.0

Win 7:

Read Full Post »

Older Posts »