Same assembly, different version, appdomain issue.

SyntaxEditor for WPF Forum

Posted 4 years ago by Frederik St-Onge
Version: 16.1.0632


I am currently facing an issue where if i delete a referenced assembly and add the same assembly, but different version, it crashes because it is already loaded in the appdomain (Even in your example project). I tried to isolate the ProjectAssembly in a separate appdomain, i've done over 30 Remoting class with MarshalByRefObject but couldn't make it work. 

Is there an easy way to clear the appdomain from loaded dll? What is the best practice in that case?

Thank you.

[Modified 4 years ago]

Comments (2)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Frederik,

This scenario is difficult because of the way Microsoft implemented reflection and its inability to reload assemblies after they've been re-generated.  There's no way to remove an assembly from an AppDomain once it's been loaded once, which is the main issue.

I wonder if you could use a separate AppDomain and in that, load up the assembly then make a new stub project assembly and set its cache path the same as the real project assembly's cache path.  Have it write out the cache data to the files.  Once that is done, back in the main app domain, load the cache data manually.

If you look in the .NET Languages Add-on's documentation's "Assemblies" topic, the last section in that topic has info on how to do those steps outside of an AppDomain.  You'd have to combine that sort of logic with AppDomain logic, but I think the concept would work.

Actipro Software Support

Posted 4 years ago by Frederik St-Onge

I will need to do more testing but it seems to work fine for now! Thank you for your support, I really appreciate it :)

The latest build of this product (v2020.1.1) was released 11 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.