Skip to content

Instantly share code, notes, and snippets.

@dotemacs
Created May 21, 2019 14:04
Show Gist options
  • Save dotemacs/5fca515345958567cc4719d56aae4b59 to your computer and use it in GitHub Desktop.
Save dotemacs/5fca515345958567cc4719d56aae4b59 to your computer and use it in GitHub Desktop.
How to import a DLL in Clojure CLR?

I can start the Clojure CLR REPL with the latest Clojure release I obtained from Sourceforge:

$ mono Clojure.Main.exe
Clojure 1.9.0
user=>

And then when I enter:

(assembly-load-from "full-path-to/Xamarin.UITest.3.0.0/lib/net45/Xamarin.UITest.dll")

I get:

#object[MonoAssembly 0x4f7758b3 "Xamarin.UITest, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null"]
user=>

But then when I try to import Xamarin.UITest like this:

(import 'Xamarin.UITest)

I get:

Bad type
NullReferenceException Object reference not set to an instance of an object  clojure.lang.Util.NameForType (:0)

Looking at this thread in Clojure CLR mail list, the user seems to have succeeded in importing his DLL after requiring additional libraries:

https://groups.google.com/forum/#!searchin/clojure-clr/how$20to$20import$20a$20dll%7Csort:date/clojure-clr/Ht0pFVWh7-I/QHuF5zLVfqkJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment