Of Code and Me

Somewhere to write down all the stuff I'm going to forget and then need

links for 2010-11-26 November 26, 2010

Filed under: Uncategorized — Rupert Bates @ 10:02 pm
 

How to include dlls added by NuGet package manager in a git repository

Filed under: Git,Visual Studio — Rupert Bates @ 9:28 am

If you have excluded dll files from your git repository with your .gitignore file but DO want to include them when they have been added via the NuGet package manager, you can add this after the dll exclude.

# Include dlls if they’re in the NuGet packages directory
!/packages/*/lib/*.dll

 

links for 2010-11-09 November 9, 2010

Filed under: Uncategorized — Rupert Bates @ 10:04 pm
 

links for 2010-10-22 October 22, 2010

Filed under: Uncategorized — Rupert Bates @ 10:03 pm
 

links for 2010-10-21 October 21, 2010

Filed under: Uncategorized — Rupert Bates @ 10:02 pm
 

error: value tools is not a member of package scala when using the scala console in IntelliJ IDEA October 20, 2010

Filed under: Error,IntelliJ,Scala — Rupert Bates @ 3:28 pm

If you get the following error whilst trying to use the scala console in Intellij IDEA:


<script>:3: error: value tools is not a member of package scala
var value: scala.tools.nsc.InterpreterSettings = _
^
<script>:4: error: value tools is not a member of package scala
def set(x: Any) = value = x.asInstanceOf[scala.tools.nsc.InterpreterSettings]
^
Exception in thread "main" java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:185)
at scala.None$.get(Option.scala:183)
at scala.tools.nsc.Interpreter.bind(Interpreter.scala:622)
at scala.tools.nsc.Interpreter$$anonfun$quietBind$1.apply(Interpreter.scala:630)
at scala.tools.nsc.Interpreter$$anonfun$quietBind$1.apply(Interpreter.scala:630)
at scala.tools.nsc.Interpreter$$anonfun$beQuietDuring$2.apply(Interpreter.scala:171)
at scala.util.control.Exception$Catch.apply(Exception.scala:79)
at scala.tools.nsc.Interpreter.beQuietDuring(Interpreter.scala:169)
at scala.tools.nsc.Interpreter.quietBind(Interpreter.scala:630)
at scala.tools.nsc.Interpreter.recordRequest(Interpreter.scala:276)
at scala.tools.nsc.Interpreter.loadAndRunReq$1(Interpreter.scala:584)
at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:597)
at scala.tools.nsc.Interpreter.interpret(Interpreter.scala:575)
at scala.tools.nsc.InterpreterLoop.reallyInterpret$1(InterpreterLoop.scala:471)
at scala.tools.nsc.InterpreterLoop.interpretStartingWith(InterpreterLoop.scala:514)
at scala.tools.nsc.InterpreterLoop.command(InterpreterLoop.scala:361)
at scala.tools.nsc.InterpreterLoop.processLine$1(InterpreterLoop.scala:242)
at scala.tools.nsc.InterpreterLoop.repl(InterpreterLoop.scala:248)
at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:558)
at scala.tools.nsc.InterpreterLoop.main(InterpreterLoop.scala:609)
at org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner.main(ConsoleRunner.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)

You can fix it as follows:

  1. From the ‘Run’ menu click ‘Edit Configurations’
  2. Select the Scala Console run configuration and type -usejavacp in the ‘ConsoleArgs’ box
  3. Click Apply

To make this the default for all Scala Console  run configurations

  1. right click on the top leve Scala Console icon and select ‘Edit Defaults’
  2. Type -usejavacp in the ‘ConsoleArgs’ box
  3. Click Ok

It should now work correctly

 

How to fix the Scala interpreter on 64 bit Windows October 13, 2010

Filed under: Scala — Rupert Bates @ 2:18 pm

If you install Scala 2.8 on 64 bit Windows using the IzPack Installer and then run the interpreter it will start up and immediately close again. If you try to run the scala.bat file that launches it from a command prompt you will then see the error ‘\scala was unexpected at this time.’

This is because by default the Scala is installed in the directory C:\Program Files (x86)\scala\bin and this directory name breaks the batch script at line 19:

set _SCALA_HOME=%SCALA_HOME%

To fix it all you have to do is change this line to:

set _SCALA_HOME=”%SCALA_HOME%”

Ie. surround the %SCALA_HOME% variable with speech marks. Note that to edit this file you will need adminstrator privileges

 

How to add a project reference – an introduction to IntelliJ IDEA 9 for Visual Studio users October 9, 2010

Filed under: IntelliJ,Java,Visual Studio — Rupert Bates @ 1:19 pm

To add a reference to an external library (the equivalent of right clicking on project references and selecting ‘Add’ in VS):

  1. Goto Project structure dialog (File\Project structure or Ctrl+Alt+Shift+S)
  2. In the ‘Project settings’ pane select Modules
  3. Make sure your project is selected in the middle pane
  4. Click the dependencies tab in the right hand pane

You can now add and delete dependencies on libraries (equivalent to adding a project reference).

There are a number of different types of depency you can add, here they are with my best guesses at how they translate into Visual Studio terminology:

  1. Single entry module – a reference to a single jar file – same as adding a reference to a dll in VS
  2. Module library – a reference to a group of jar files (accessible only to this module?) – no real equivalent in VS
  3. Project library – a reference to a group of jar files (accessible to whole project?) – no real equivalent in VS
  4. Global library – a reference to a group of jar files (accessible to all projects?) – similar to adding a reference to a dll in the GAC
  5. Module dependency – a reference to another project – same as a project reference in VS
 

Publishing to multiple queues from NServiceBus September 9, 2010

Filed under: NServiceBus — Rupert Bates @ 3:38 pm

Something that I found a bit confusing when setting up NServiceBus, was working out how to publish to multiple queues when I have a number of different services and message types.

The project structure I have is:

MyProject.WebApp – handles config and takes commands from user

MyProject.Messaging – defines messages and has utility classes for publishing which are called by the web app

Myproject.Service1 – reads from a message queue and does something with one type of message

Myproject.Service2 – reads from a different message queue and does something with another type of message

etc.

The confusion I had was around how to configure my web app to send different types of message to the correct queue, all the documentation is there on the NServiceBus site, it’s just not that easy to apply.

It turns out the solution is actually very simple, in the config for my web app I just need to include the message type names and the assembly they appear in to map those types to the correct queue, as follows:

  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="MyApp.Messaging.MessageType1, MyApp.Messaging" Endpoint="MyApp.Service1.InputQueue"/>
      <add Messages="MyApp.Messaging.MessageType2, MyApp.Messaging" Endpoint="MyApp.Service2.InputQueue"/>
    </MessageEndpointMappings>
  </UnicastBusConfig>
 

Run NServiceBus generic host as 32bit process on 64bit machine September 7, 2010

Filed under: Error,NServiceBus,Systems Administration — Rupert Bates @ 3:37 pm

I recently encountered the following error when deploying a service in the NServiceBus generic host (NServiceBus.Host.exe) on a 64bit machine,


System.InvalidOperationException: The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.

It turns out that this is actually a symptom of a problem which can show itself in a number of ways and is caused by running a service which depends on a 32bit dll (in this case the Microsoft Jet drivers) on a 64bit system in the generic host.

To fix it you can create a version of the generic host which is configured to run as 32bit as follows:

Run a visual studio command prompt and cd to the directory where NServiceBus.Host.exe is.  You will also need the NServiceBus.snk file from the NServiceBus download in the same directory so that you can resign the assembly after configuring it

At the command prompt type:

corflags /32BIT+ /Force NServiceBus.Host.exe

sn -R NserviceBus.Host.exe NServiceBus.snk

You can now deploy this version of the host onto your 64bit server and services which use it will run in 32bit mode