CommandsService.LoadAssembly should not attempt to install modules without a valid constructor.
See original GitHub issueIn the current behavior, if a module has an invalid constructor (e.g. requiring a DiscordSocketClient), the LoadAssembly
method will throw an InvalidOperationException
and crash.
In some cases, users may intend to have only certain modules use custom constructors, while leaving the rest of their modules default.
Projected Change: If the assembly crawler fails to find a valid constructor for a class, skip over that module, rather than hard-failing.
I can create a fix if this issue is deemed unintended behavior.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Not allowed to load assembly from network location
I've recently set up a new Windows Server 2012 R2 environment and installed Visual Studio 2012. Now I'm having a problem with multiple...
Read more >How to: Load Assemblies into the Reflection-Only Context
Code loaded into this context can only be examined; it cannot be executed. This means that objects cannot be created, because constructors ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Along with what @khionu and @420foxbot suggested, I think it would also be useful to pass the CommandsService instance in the module constructor. I have to use a static variable to pass it as I need the CommandsService instance to implement a
help
command, and it was also useful to implement commands to help debug type readers.The constructors I’d want would probably be something like this:
As for user feedback on modules failing to load, I’d say issuing a Warning and continuing the load would be the best approach. If an attribute were introduced, it would probably be better to mark classes we don’t want to autoload, rather than classes which should autoload, as it makes it clear we have to explicitly load the module rather than have it load automatically.
As per Discord convo:
CommandsService
I guess), route everything through an optional simple DI (little more than a user friendlyDictionary<Type, object>
)