- Home /
Can't replace DLL file after running.
I've asked this question before, but due to the nature of these stack overflow-like forums, any modifications to the question do little to bring it to anyone's attention, and making substantial changes to a question are frowned upon.
So, I'll try asking this in a different way.
I need to replace a plugin DLL frequently, as it is part of the testing process. I build the DLL with MSC, and run it with a C# script in Unity. The problem is, after it is used only once by a script, the module remains in use until the editor is restarted (that is, I cannot delete or replace the file, either manually or through another program).
This tells me that the C# runtime that Unity is using is not releasing references to modules that are not in use after scene scripts have stopped running.
I wrote a little test module that produces a message box when DllMain gets called with DLL_PROCESS_DETACH
. After I run and then stop a script that loads it, the message box does not pop up until I close the editor.
I understand that the runtime dynamically loads the script and its dependencies while the editor is running, and playing/stopping the game does not necessarily mean that any modules loaded by scripts are unloaded.
MY QUESTIONS ARE:
How can I force the editor to unload a module without having to restart it?
Is there a list of loaded modules somewhere I can access that would allow me to force an unload?
Gah this problem is making development borderline impossible - have to restart unity editor after every code tweak! No solutions yet?
Answer by xCyborg · Feb 01, 2019 at 11:50 PM
Seven years later nothing has been done to address this issue.
It's impossible to iterate on testing plugins, why this is not addressed?
Answer by Demigiant · Jan 19, 2012 at 05:44 PM
This happens all the time if you have placed your DLL in the "Assets/Plugins" folder. If the DLL is not truly a plugin but just an assembly, placing it into any other folder will fix this issue (almost - it will still happen from time to time, but much more rarely). If instead it's a true plugin, I apologize for the useless answer :P
Answer by Jashengmato · May 19, 2013 at 09:53 AM
Create a method to manually stop the threads and release all the resources.
Invoke this method in OnApplicationQuit.
This may work! :)
Your answer
Follow this Question
Related Questions
Sending and receiving variable-length arrays to and from DLL 0 Answers
Multiple Cars not working 1 Answer
Problem importing a mixed-mode (C++/CLI) library 2 Answers
Win Store plugin causing internal compiler error 1 Answer
Distribute terrain in zones 3 Answers