I am trying to create a single executable from the binaries of a project. This is what I have:
- A shared library dll, written in F#, I will refer to it by
A - A library dll, written in C# that implements a module interface (
IModule) fromA. I will refer to this library asB - An executable, written in F#, that at bootstrap time detects all available implementations of the
IModuleinterface fromAand instantiates the respective types - there is such implementation inB. I will refer to the executable asC
All projects target .NET 4.0; the F# projects use F# 3.0 (FSharp.Core 4.3.0.0), I am using Visual Studio 2017 Community.
All the logic is working fine when the files are not packed together (as if ran from the exe project's bin/Debug directory). When I produce the merged executable (using ILRepack ), then the logic in the executable no longer detects which classes from B implement interfaces from A. In particular, I have the following check:
if (typedefof<IModule>.IsAssignableFrom(someType)) then ...
which is a code fragment from A that I use to detect IModule implemenations. I suppose the ILRepack merging causes some type information to be lost in the process, preventing the above line from working.
A solution I used to get this work was to exclude the library A from the merged exe and just bring it along.
Is there a way to still have a single executable and get the type detection working? I'd prefer using a similar approach as the above interface detection, because once I find the desired types, I need them to be cast to IModule in order to further use them in my code.
My goal is to have the above 3 libraries bundled together in a single executable. However I'd also want to have other dll files, which implement IModule from A and be placed besides the executable. These dlls will be developed independently from A, B and C and their presence around the merged executable will vary depending on my use cases. I cant get them to work for the same reason.
Note, I also include the FSharp.Core dll in the packed executable for obvious reasons.