An "could not copy temporary files to the output directory" error is generated in Visual Studio .NET or in Visual Studio 2005 (311491)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
- Microsoft Visual J# .NET (2003)
- Microsoft Visual J# .NET (2002)
This article was previously published under Q311491 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
BUG: "Could not copy temporary files to the output directory" error message when you build a solution that contains multiple projects
CAUSEThis 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. RESOLUTIONResolution to Cause 1 To resolve this behavior, save the project that references the assembly. Then, close
Visual Studio .NET or Microsoft Visual Studio 2005 to unload the assembly from memory. To prevent the error from occurring again, set the Copy Local property of the reference to True. To do this, follow these steps:
- Open the solution that references the assembly.
- In Solution Explorer, locate the project that references
the assembly.
- Click the References node of the project.
- Right-click the assembly reference, and then click
Properties.
- Set the Copy Local property to True:
- Save the solution.
Visual Studio .NET or Microsoft Visual Studio 2005 copies the referenced custom control file to
the output folder of the consuming project. Therefore, Visual Studio. NET or Microsoft Visual Studio 2005 does not
load the assembly from its original \Bin folder. Resolution to Cause 2Solution 1- Quit all running instances of the application.
- Build the solution. To do this, use one of the following methods:
- On the Build menu, click Build Solution.
- Press CTRL+SHIFT+B.
Note If you receive the error message, follow the steps in the "Solution 2" section.
Solution 2- Press CTRL+ALT+DEL to start Task Manager.
- On the Processes tab, make sure that your application is not listed as a running process. If it is,
select the process from the list, and then click End Process.
Note Make sure that you have not selected any additional processes,
because ending other processes may cause unwanted results. - Click Yes to end the application process.
- Build the application in Visual Studio .NET or Microsoft Visual Studio 2005.
STATUSThis
behavior is by design.
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbProd2Web kbnofix kbprb KB311491 kbAudDeveloper |
---|
|