An “could not copy temporary files to the output directory” error is generated in Visual Studio .NET or in Visual Studio 2005
Symptoms
When you build a project in Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005, the build fails and you receive the following compile-time error message:
Could not copy temporary files to the output directory. For more information about another cause for this symptom, click the following article number to view the article in the Microsoft Knowledge Base:
313512?(http://support.microsoft.com/kb/313512/) BUG: “Could not copy temporary files to the output directory” error message when you build a solution that contains multiple projects
Resolution
This behavior may occur for one of the following reasons.
Cause 1You may receive this error message when you compile a component that is currently being used by another process. For example, you may try to compile a class library or a user control project. For example, this behavior may occur when the following conditions are true: Multiple instances of Visual Studio .NET or Microsoft Visual Studio 2005 are open. In one instance, you have a UserControl or class library project. In the other instance, you have a project that references the component and the project of the component is open in the first instance.The second instance uses a file reference to the assembly and the Copy Local property of the assembly is set to False.The assembly has been loaded into memory of the second instance of Visual Studio .NET or Microsoft Visual Studio 2005.If the Copy Local property is set to False for the referenced assembly, and the assembly is not installed in the global assembly cache, the assembly will not be copied to the local \Bin folder of the consuming project. To resolve the location of the referenced assembly, Visual Studio .NET or Microsoft Visual Studio 2005 will search the paths that are listed in the Reference Path property of the project until it finds the assembly. In a scenario where the assembly has been loaded, such as a UserControl loaded in the Windows Form designer, the assembly is being used and cannot be overwritten when you try to build it. When this behavior occurs, you receive the error message that is mentioned in the “Symptoms” section.
As soon as the assembly has been loaded in memory of the Visual Studio .NET or Microsoft Visual Studio 2005 IDE, the assembly will not be unloaded until you exit and then restart the Visual Studio .NET or Microsoft Visual Studio 2005 IDE. For more information, see the “Resolution” section.
Cause 2 This behavior also occurs if you try to build the application when you are currently running an instance of the application from its \Bin folder, externally of the Visual Studio .NET or Microsoft Visual Studio 2005 IDE.
During the build process, the compiler builds the project to an intermediate folder, such as Obj\configname. In this folder name, configname is the name of the project. When the build process has completed, the files are copied from the intermediate folder into the output folder. The “Could not copy temporary files to the output directory” error message indicates that the compiler could not copy these files from the intermediate folder to the output folder. If you run the application that is being built from the output directory, the compiler cannot overwrite these files because they are currently being used. For more information, see the “Resolution” section.
