How Do I Fix the Compile Error when an Assembly Can Not Be Copied?

When you have tried to add code to the AUT with the LoadAssembly method, you might get the following compile error:
Could not copy '<assembly_name>.dll' to '<assembly_name>.dll'. The process cannot access the file.
The reason for this compile error is that the assembly is already loaded in the AUT and cannot be overwritten.
To fix this compile error, close the AUT and compile your script again. To avoid that problem in the first place, copy the assembly into your script, for example to a temporary directory, and then inject the copied assembly with the LoadAssembly method. For example:
' VB code
Dim typeThatContainsYourStaticMethod = GetType (UltraGridUtil)
Dim assemblyToLoadIntoAUT = typeThatContainsYourStaticMethod.Assembly.Location
Dim tempFile = IO.Path.GetTempFileName()
IO.File.Copy(assemblyToLoadIntoAUT, tempFile, True )
mainWindow.LoadAssembly(tempFile)