Problem with plugin reloading

 
 
 
Posted by:ofer_z
Data created:15 July 2010

Hi,

I've tried to set up dynamic reloading (I checked the unload plugins option in the utility panel and restarted max). It seems my plugin is reloaded when I re-build it and copy it to the plugins/maxdotnet folder (I write some text to the listener in it's init method), but it seems like the plugin itself isn't update. Like it's just re-initializing the same plugin as was before.

At first the plugins wouldn't load at all in that folder, but I fixed that by adding the maxDotNet folder to max's plugins folders.

This issue happens on both max 2010 and 2011 both x64. I'm running windows 7 x64.

Any help would be much appreciated, as it's a pain to restart max every time I re-build the plugin.

 

Thanks,

o

Hey,

I'll have a look at this Monday (away for the weekend). I noticed that reloading works fine for me on 2010 but not on 2011. You might need to change the assembly version number because the previous assembly is not unloaded, rather just the new one is loaded on top.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Hi Marsel,

Any updates on this? It's really annoying to have to restart max, especiall since I'm just starting with the SDK and maxDotNet and can't seem to get debuggin to work with sharpDevelop, so I have to compile a lot to test :)

 

Thanks,

o

Hi Ofer,

I haven't looked at this yet and probably will not have much time to do so before Siggraph (I am planning on making a new build then and looking at this issue). Debugging should work fine though, just make sure that you have the .pdb symbols present in the same directory as the .dll and that you attach your debugger to the 3dsmax process.

Cheers

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Hey Marsel,

Just tested the plugin reloading with 1.2.4 and it works! Thank a lot!

 

Cheers,

o

Hey Marsel,

It seems I spoke too soon, the update is still somewhat broken.

It appears that only the plugin members are updated, but the rest of the class is not, but I'm not sure exactly about which parts are being updated and which aren't. I have a simple class derived from IPlugin, and in it's Initialize method I put a print to the listener so I know when it's loaded. I made some changes to the class and also updated that print out, the new text was printed to the listener, but the new functionality in the class wasn't working (I changed a method, didn't add any new ones). After I restarted max, the new functionality worked.

I hope that's enough information for you to track it down.

Thanks,

o

 

Hi Ofer,

I suspect this is due to .NET assembly versioning, I ran into this issue at first as well. Max.NET does not unload previous assembly from memory before loading the new one (thats one of the limitations of .NET), so it is possible that it will still use classes and methods from previously loaded assembly, even if it reloaded the new one.

What I do in Zookeeper is change the build number automatically every time Visual Studio builds the project. This can be done by changing the last version value in AssemblyInfo.cs to "*", it is outlines nicely here.

This way whenever you overwrite your assembly Max.NET will load a different build and will be able to discriminate between the classes in the two builds. It will then first call the previous build's IPlugin.Cleanup(...) and then call new build's IPlugin.Initialize(...) method.

Hope this helps

Marsel Khadiyev (Software Developer, EPHERE Inc.)