OpenBVE icon indicating copy to clipboard operation
OpenBVE copied to clipboard

Allow to load dependencies of train plugins

Open HengYeDev opened this issue 3 years ago • 7 comments

I am currently writing a plugin which uses a few DLL dependencies. The LoadFile method does not allow to load these dependencies, but the LoadFrom method does.

HengYeDev avatar Jun 18 '22 15:06 HengYeDev

Are you sure this is needed?

This should already work (indeed BVEC_ATS already loads a couple of external dependancies), and the basic difference between LoadFile and LoadFrom is what happens in terms of further dependencies down the chain not found in the GAC.

leezer3 avatar Jun 18 '22 16:06 leezer3

I believe so, I had a dependency that depended on other dlls and it wouldn't work with the current openbve

HengYeDev avatar Jun 18 '22 16:06 HengYeDev

by the way, I am using linux (mono) if that makes a difference...

HengYeDev avatar Jun 18 '22 17:06 HengYeDev

Can you share a copy of your plugin / source at all please? (Just a link to the dependancy might work, but preferably the entire thing, as it may well be something in your setup)

It'll be much easier to see what's going on in the debugger, and I'd suspect that you're missing a binding redirect somewhere, causing it to load something unexpected via LoadFile. At an * educated guess* without seeing things, I'd suspect that you might need to copy in the appropriate .dll.config file for your dependancy.

leezer3 avatar Jun 21 '22 11:06 leezer3

Give me a few days to push my plugin up, but I'm using EmbedIO https://unosquare.github.io/embedio/

HengYeDev avatar Jun 21 '22 20:06 HengYeDev

Interesting :) The plugin interface isn't really designed to run a webserver (it's single threaded / blocking, so I'm presuming you're spawning a background thread?), and we've definitely seen issues with this sort of thing before. IIRC in that case it was someone launching an embedded browser for an in-game login, but essentially anything that wants to control its own threadloop may be problematic.

leezer3 avatar Jun 21 '22 20:06 leezer3

I think embedio uses its own thread, it works great for me to display a speedometer and some variables on a browser window and I haven't found any performance issues so far

HengYeDev avatar Jun 21 '22 20:06 HengYeDev