Unload .Dll , using as a plugin?



I know this has been discussed before, but I came across this site.


Would it be possible to load in a custom .dll in a plugin, then use his script to unload it, so that we could make changes to a .DLL without closing/re-opening max?



A coworker of mine tried it with a controller plugin he was developing, and while it successfully unloaded the dll, that did not help much, as 3dsmax would crash immediately after. Perhaps you will have better luck with a different type plugin.

A different type of solution is to add a pre-build action that kills the 3dsmax process and a post-build action that relaunches it.


Yeah… Damn. The kill/launch idea would help too I suppose. Thanks :slight_smile:


i’m 100 % sure that we are talking about .net/c# dll.
it can’t be unloaded with the utility that you point to.

the way that i do the .net/c# dll debugging is the using of dynamically loaded dll. it allows you to recompile the dll without reloading the system:
the original idea by Gravey
my version:


if its c++…

  • test your plugin
  • save scene
  • reset max
  • unload plugin
  • change code/compile
  • reload plugin
  • load test-scene

if you have something in your scene which is using your plugin, max will crash after unload cuz the code is gone
didn’t try it, but should do




So Dennis, when you said,

it creates new assembly the same way as in your code.
And of course we have to use CreateInstance assembly method to create
classes from newly created assembly. MAX dontenobject and dotnetclass
methods create object(class) using first loaded assembly.

Did you mean that I should load my dotNetObject first, then the other Dlls I might use? I tried loading all 3 of my Dlls with your method, and it fails on this custom Multi-selection TreeView I have. This is the error I get.

MAXScript MacroScript 
Error Exception
-- Runtime error: dotNet 
runtime exception: Could not load file or assembly 'TreeViewMS, 
Version=1.0.960.12060, Culture=neutral, PublicKeyToken=null' or one of its 
dependencies. The system cannot find the file specified.


i don’t know what your dlls do… technically they might need specific loading order. Can you load them using dotnet.loadAssembly method?


They work fine if I load them with the dotnet.loadassembly . Its when I tried to use your other method, I got that error. i tried switching around orders and it didn’t seem to work, but I’m going to try it again once.

I don’t need my FreeImage or TreeviewMS DLLs to load in dynamically, only my main one.

So technically, I should be able to over-write my custom DLL then and it should work otherwise, correct?


and is any way to UnLoad .net dll and free used memory? just to ask tho


Well, I think that happens when you use his method he said.

Since it’s loading the dll into the reflection or whatever in realtime, I would assume max garbage collects it when you close your UI or whatever was using the code to start with.

I need to mess around with this more yet and see if I can get it working. I really really hate having to restart max everytime. But it’s not as bad at home as here at work. It takes like 2x as long to restart max than at home.


Awesome, so I got it to work :slight_smile: Thanks alot Denis!

I just added my TreeViewMS .cs into my file , instead of including the .DLL. So now when I do the readbytes, it all loads in just fine :). This will make modification MUCH faster now :slight_smile:

Edit: Nevermind… It seems to load it fine… but I need to unload is somehow so it updates properly. I have a global hanging onto the dotnetobject, so I need to dispose that or something… except dispose doesnt work.


i know you can :wink:


Well, unfortunately I went back to loading the .DLL how I was, because the TreeView was giving me issues. Also, that and max seemed to hold onto my old data, but I could over-write my dll. So even though I could over-write it, it didn’t update in max anyways.


after you reload an assembly you have to use CreateInstance method to create objects from newly loaded assembly.
dotnetobject and dotnetclass methods keeps create objects and classes of first loaded assembly (not the last one).


Ah, ok. Well maybe I’ll give it a shot again. That Treeview gives me issues though. Right now Im including it as a DLL. I tried adding the project as a reference, and it was working, but then I was getting errors all of a sudden.


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.