Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala on .Net HelloWorld

Tags:

.net

scala

Following the README at https://github.com/magarciaEPFL/scaladotnet to create a Windows exe for a simple "Hello World" app:

package hello.world

object Main {
  def main(args: Array[String]) {
    println("Hello, World!")
  }
}

Built .exe with the command from the README:

scalacompiler.exe ^
-d C:\test\bin ^
-target:exe ^
-Ystruct-dispatch:no-cache ^
-Xassem-name HelloWorld.exe ^
-Xassem-extdirs C:\scala.net ^
-Xshow-class hello.world.Main ^
C:\test\src\HelloWorld.scala

While using Windows 7 Pro, 64bit, I receive this error when attempting a run:

C:\test\bin>HelloWorld.exe

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'scalalib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. at Main(String[] args)

The Scala .Net compiler directory is directly in the path, yet it appears that the HelloWorld.exe is unable to find and load the scalalib.dll that is in that directory. As per the comments below, copying the HelloWorld.exe directly into the C:\scala.net directory, and executing from there, works as expected. But, placing the .exe into another directory, and the C:\scala.net dir as part of the PATH, does not.

What is wrong?

like image 692
scaling_out Avatar asked Aug 01 '12 13:08

scaling_out


1 Answers

The .NET Framework does not follow Win32 in using the %PATH% environment variable for locating assemblies.

The short answer is: If it's not in the same folder, then it needs to be in the GAC, or it won't be found.

Also, see this question.

like image 174
rossipedia Avatar answered Sep 21 '22 09:09

rossipedia