Closed physics-sec closed 4 years ago
The part you're missing is that dependency assembly loading happens lazily in the CLR, rather than eagerly. You're using the duck
type in the numberOfCPUCores
method. This is implemented via an interface defined in Boo.Lang.dll
, so the CLR tries to load the assembly when it enters that method, rather than at the start of the program.
If you loop over every assembly loaded in the current AppDomain before you've run that method, it won't show Boo.Lang because it hasn't been loaded yet. If you were to run that code after numberOfCPUCores
, you would see it in the list.
Thank you for the fast response!
Your are right, it does appear after I called the numberOfCPUCores
method.
Although I still have the issue that when I run program.exe
on a folder without the DLLs, it fails (because it can't find the Boo.Lang
assembly). Any ideas how can I fix this?
You fix it by putting Boo.Lang.dll
in the same folder as program.exe
when you deploy it. Or by not using any types or features that need that assembly, such as duck
. Or if you want to really get fancy, you can use a tool like ILMerge to merge the DLL into the EXE. But the simplest solution is to just make sure your dependencies are where they're supposed to be: alongside the EXE..
Great! thank you very much 😄
Hi! I'm having some issues compiling Boo source code to a .exe with the
booc.exe
compiler.This is my program:
As you can see, it prints the amount of CPU cores.
I compiled it with this command:
If I run
program.exe
inboo/bin/
(where all the DLLs are) it works perfectly:If I run it in my destktop (or some other folder without the boo's DLLs) I get this:
While compiling, I'm referencing the
Boo.Lang.dll
assembly, shoudn't this make the binary executable on any Windows system?If I print the assemblies with:
I get:
So, it seems that the Boo's DLLs are not being referenced?
What am I doing wrong?
Thank you in advance!