Hosting WCF in IIS 7.0 / Windows 2008

by Mikael Henriksson 25. November 2009 11:57

If found this to be helpful

  1. Run an elevated command prompt
  2. Run the following command:
    "%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r -y
  3. Last and also very important is the need for a base address, it seems IIS 7 does not figure this out by itself:
  4. <system.serviceModel>
    	<services>
    		<service name="RESTService.Service" 
    				 behaviorConfiguration="Default">
    			<host>
    				<baseAddresses>
    					<add baseAddress="http://localhost:80/" />
    				</baseAddresses>
    			</host>
    			<endpoint address="" 
    					  behaviorConfiguration="Default" 
    					  binding="webHttpBinding" 
    					  contract="RESTService.Service" />
    		</service>
    	</services>
    </system.serviceModel>

Just speficy the baseAddress and you should be good to go. Navigate to your svc file and you can start consuming it.

Tags:

WCF | Windows Server

NHibernate Profiler a real time-saver

by Mikael Henriksson 13. November 2009 01:34

It’s great for several reasons. I’ll try and cover some of them briefly

  1. It detects possible problems with your configuration / mappings and this is fantastic. You spot those N+1 and Unbounded result sets before someone complains about a crash or performance issues.
  2. It outputs the SQL in a very understandable and readable format. I never could stand watching the SQL Profiler.
  3. It tells you about internal NHibernate errors. I spent too much time opening management studio trying to see if things ended up in the database or not. If there is an error it’s likely I don’t have to bother.
  4. It tells you if a query was read from the cache or database. I had some implementation problems that cause my queries to always be fetched from the database without nh prof it would have taken me some time to figure out why.
  5. It is so easy to use. Add a reference to the Appender.dll and make sure you run Initialize() on the chosen profiler and your done.

Try it out http://nhprof.com/download

Tags:

NHibernate

What does Rob Conery have against strings?

by Mikael Henriksson 12. November 2009 17:08

Well I sort of get it can be a pain in the ass to have to deal with strings. But what if you also have to deal with VB.NET at the same time? I just have to show this nice little helper I have.

Public Function ConvertToDictionary(ByVal input As String) As IDictionary(Of String, String)
	Dim dic As New Dictionary(Of String, String)
	Dim pairsplitter As Char = Char.Parse("&")
	Dim keysplitter As Char = Char.Parse("=")
	Dim stringArray As String() = input.Split(pairsplitter)

	If (input.Length > 0) Then
		If (stringArray(0).Contains("?")) Then
			Dim tmp As String = stringArray(0)
			stringArray(0) = tmp.Remove(0, tmp.IndexOf("?") + 1)
		End If
	End If

	For Each keyvalpair As String In stringArray
		Dim keyarray As String() = keyvalpair.Split(keysplitter)
		dic.Add(keyarray(0), keyarray(1))
	Next

	Return dic
End Function

The fun part is when you have created your unit test and it succeeds. The boring part is revisiting such a bastard after a year trying to figure out what the hell you where doing there in the first place. Oh and to answer your question. The reason for all this is that sometimes the input stream contains the page.aspx? and sometimes it just starts with the key-value pairs and since I don’t want the page.aspx? as a key in the dictionary I remove it and replace whatever is in array(0) :) Fun times…

Tags:

vb.net