When creating and testing a registered assembly (e.g. an assembly registered via TCI), it is possible to run into a file locking issue that causes compilation to fail. While there are a few different manifestations of this particular issue, the root cause is the same. Visual Studio 2010 treats any assembly found in the GAC, Private Assemblies folder, or Registry as a framework assembly and thus locks these files. Once these assemblies are loaded by the designer, any attempt to copy over them will fail with the following error message:
Unable to copy file "obj\Debug\<Assembly Name>" to "..\..\<Assembly Name>". The process cannot access the file '..\..\<Assembly Name>' because it is being used by another process.
It does not matter if this copy is happening as the result of a compilation; build action, or manual copy. Once these assemblies are loaded by Visual Studio, they will be locked and attempts to overwrite these files will fail.
To avoid this scenario, you should follow these rules for development and deployment testing of your registered assemblies:
First, it's important to point out that TCI registration is not required to develop/test/debug design-time features. It is recommended that you separate out the functional testing of control libraries from the testing of deployment scenarios. One easy way to accomplish this is to create a test project directly in your working solution. This will allow you to take full advantage of the Toolbox Auto-pop and will make it easy to create controls from the toolbox, all without the need for TCI registration. You do need to ensure that the controls that you are building have not been placed in the GAC, Private Assemblies Folder, or in the registry (such as under the AssembyFoldersEx node).
Please contact us if you need additional help with this issue.
WPF & Silverlight Designer Team