Posted 4 months ago by Gavin Huet
Version: 23.1.2
Platform: .NET 6.0
Environment: Windows 11 (64-bit)


We have encountered an issue where if we load up an external reference assembly into the script editor, a lock is placed on the file itself and is not released until we close the application.

In our example we load up an assembly in the TEMP directory, and when the Dispose method of our class is run we clear the assemblies e.g.

If mVBProjectAssembly IsNot Nothing Then mVBProjectAssembly.AssemblyReferences.Clear()
If mCSharpProjectAssembly IsNot Nothing Then mCSharpProjectAssembly.AssemblyReferences.Clear()
mVBProjectAssembly = Nothing
mCSharpProjectAssembly = Nothing

At this point if I try to delete the file in the TEMP directory it will say it there is a system lock on it, and this will stay until I close the applciation.

Now I believe this is by design by .net for security reasons, but can you confirm that there is nothing else we can do to release that lock?


Comments (2)

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

Hi Gavin,

.NET reflection will lock an assembly on load, which is the problem you're running into.  Please see this documentation topic for details on that.  Unfortunately we have no control over that since it's part of core .NET.

We also have the ability to use Roslyn as an alternative to reflection.  We implemented this as an alternative option to work around that  locking issue.  The section in the same topic after the linked section talks about using that option.

Actipro Software Support

Posted 4 months ago by Gavin Huet

Thanks, that worked perfectly!

The latest build of this product (v24.1.0) was released 8 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.