Small Basic Forum
Import needed class only - Printable Version

+- Small Basic Forum (https://litdev.uk/mybb)
+-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1)
+--- Forum: Extensions (https://litdev.uk/mybb/forumdisplay.php?fid=3)
+--- Thread: Import needed class only (/showthread.php?tid=116)



Import needed class only - hybridClasher.init() - 08-12-2024

Hi all,

I am using ILMerge.exe to convert my small basic exe and dlls to a standalone exe (for sake of sharing). Obviously, ILMerge needs ALL of the Microsoft.Expression.Effects, Drawing, System, etc etc too which would be very annoying. Is there any possible way from which i can only include the needed class in my code or reference the only needed .dll in my directory? (e.g LDCmd.dll, etc)

P.S: Programically speaking, this means "By breaking the extension in parts".

I would be grateful for your help,
Thanks.


RE: Import needed class only - litdev - 08-12-2024

Hi,
Not sure I totally follow.  This is my understanding:
You have created a SB program, and compiled it.  You want to combine the required dlls into the exe with ILMerge.

Lots of dlls are added to the exe folder (everything in lib).  To see which are actually needed, recmpile to a new folder and try removing (or renaming) dlls until you have just those actually required.

Existing dlls cannot be split, so there is not such thing as LDCall.dll.

Is is usual to add exe and all required dlls in a single folder, zip this and share the zip, with instructions to install - download, unblock, unzip, run exe.

There are free installers you can use that effectively zip everything into setup file (exe or msi).  These are actually just zips with some scripting to install the bits in the zip.  Also I recently used itch.io for a couple games, and it has nice download/install/run features - you just upload a zip with everything required in it.

If I am missing the point, then please provide more details.

EDIT

If all you need is LDCall, then I guess you could just copy the code and compile it yourself as a small dll - I could help with this.


RE: Import needed class only - z-s - 08-13-2024

How you are using drawing and etc dll in sb I can't understand if you need to merge the exe and the extension of sb only
All .net dll are in every pc


RE: Import needed class only - hybridClasher.init() - 08-13-2024

I see there's a bit of confusion here, I'll break it down.

I have LitDev.dll and SmallBasicLibrary.dll along with the exe file. Runs perfectly fine.

However, I want to use ILMerge to merge the dll files with my program to make it only one exe.

This is the issue that occurs: https://pastebin.com/Uv0HTigg

Now, i thought this was probably just because i didnt include SlimDX.dll in my directory, so i did.

Same error this time, but instead, with Microsoft.Expression.Effects.dll

So i included that in my folder too, and more and more dll errors started to come up.

What I think is the problem here is that ILMerge is using all of the classes in LitDev.dll which is causing so many dll errors.

Of course though I'm not a maniac and wouldnt want to include each dll file in my directory, time wasting and resulting in a bigger file size.

I'm trying to achieve a solution for this, I am using LDDialog in my program, and as we all know small basic doesnt support import statements, so the only solution (What i think) is to break the extension in different parts e.g Call.dll, GraphicsWindow.dll, etc etc. Maybe using steve's source code?


RE: Import needed class only - litdev - 08-13-2024

I'm afraid its abit complex because DitDev.dll is compiled against native code (eg SlimDX that cannot be ILMerged).  The native code is not ILMerged into LitDev.dll, but held in resources to be extracted as required.

Its not a simple fix.

So your options are:

1] To ship a couple dlls with the exe
2] Bundle in a zip, using an installer if you want
3] Try to break and compile specific source code you want into your exe

Frankly, I don't see a reason to not do 1 or 2 unless you are having fun trying to combine everything.


RE: Import needed class only - hybridClasher.init() - 08-13-2024

Hi,

Turns out, me being the silly one, i was referencing SlimDX.dll and all the others too, whereas i only needed to reference smallbasiclibrary and litdev, not all the others too. ilmerge only needed around 2 or 3 remaining dlls in the directory including microsoft.expression.drawing (i was using a brush type of project so i makes sense). However, the output was still around 9mb, which is a bit absurd for a brush effect project, but if im being honest its better not to mess around with that or else ill dig myself into a deeper hole.

Thanks for your help.


RE: Import needed class only - litdev - 08-14-2024

Not sure I really follow, but glad you got it sorted.