Unable to copy file C:\SomePath\Myfile.dll to bin\Myfile.dll Access to the path bin\Myfile.dll is denied - visual-studio-2010

We just converted a VS 2008 project to VS 2010. The conversion showed no errors. Now, when building the solution. We get the following errors:
Unable to copy file C:\TI\Project\SharedAssemblies\Myfile.dll to bin\Myfile.dll Access to the path bin\Myfile.dll is denied
ANOTHER PROBLEM:
I have another problem too! One of my project is referencing a project DLL and that DLL does not exist. I tried to build the solution but that project is never building because it stops whenever there is error on any other project.
UPDATE 2:
So, instead of using the ported VS 2008 to VS 2010 solution I just opened the VS 2008 solution in VS 2010 and some of the errors have gone away. Now, I am left with couple of errors in which one of them is the following:
Error 1 Could not load referenced assembly "C:\MyProject\bin\JobManager.dll". Caught a FileNotFoundException saying "Could not load file or assembly 'C:\MyProject\bin\JobManager.dll' or one of its dependencies. The system cannot find the file specified.". C:\MyProject\ResGen
What kind of resources the resgen is trying to build and where is it located?

One common cause that I've encountered is that a unit test has the assembly loaded (like in NUnit) and that is blocking the copy. Closing NUnit, for example, clears the problem. Check for something similar that's holding on to the assembly.

I just removed the file from bin folder and everything start working
might be it help you!

Related

Visual Studio Could not load assembly

I have a C# project using MySql.Data and EntityFramework, and have used the Data Entity Model Wizard to create code based on an existing database. I created the project on a machine running MySql Server 8.0.25 (where I cannot control the installed version), so all my references for MySql packages are also version 8.0.25.
When I moved the project onto my own machine, running MySql Server version 8.0.31, the project successfully builds but has an error message, which Visual Studio says comes from a .edmx file:
Error 4: Could not load file or assembly 'MySql.Data, Version=8.0.31.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ... ScheduleModel.edmx 7
The file in question only contains the text "MySql.Data" in one place, and that's an un-versioned reference to "MySql.Data.MySqlClient", on line 7.
Since the project builds and appears to run correctly, I don't know if this error affects anything. Regardless, I would like to understand it and why it happens and ideally make it go away.
Here's what I've learned form searching for an answer and trying to investigate/fix the error:
There are no references to version 8.0.31 anywhere in my project, as using Visual Studio to search the entire project for "8.0.31" found no results.
Answers to others' questions tell me the version number in the error message specifies the version of a file that Visual Studio DID find. (Whereas I would have thought the given version number is the one that it is LOOKING for.)
Several places said that the found version is probably in the GAC. Originally, the error message said MySql.Data.EntityFramework (not just MySql.Data), and I did find MySql.Data.EntityFramework in the GAC. (No idea how it got there.) After removing it, the error message changed to just MySql.Data. However, MySql.Data is not in the GAC, and no MySql.Data.* are still there either.
There's a tool called fuslogvw.exe that supposedly can help with this issue, but I could not get it to work. When I run it, there is nothing in the log. When I click on options, all options are grayed out. The one person's recommended registry edit did not work either. (I tried closing and re-opening Visual Studio after said edit, then re-building.)
Process Monitor tells me that, during the build process, no processes accessed any files that include "MySql.Data" in the name except those under packages/MySql.Data.8.0.25 and the project's output directory; all files are version 8.0.25. This appears to conflict with #1, because how can Visual Studio have found version 8.0.31 if it never accessed any such file?
I tried using bindingRedirect in App.config to redirect from 8.0.31 to 8.0.25, which had no apparent effect.
Cleaning the solution and re-building ends up putting MySql.Data version 8.0.25 back into the output directory, so Visual Studio clearly is finding the correct version.
Deleting the packages folder results in everything being replaced (with the right version, again) but the error message persists. (The rebuild was strangely fast; I'd have thought everything would have to be re-downloaded, but it was too fast to have done that.)
How would I diagnose this issue? What might be causing Visual Studio to look for or to find a version that I cannot find any reference to, or any .dll file for?
I'm using Visual Studio Community 2019, Version 16.11.2.

The application was unable to start correctly (0xc000007b) when copying from one project to another

I'm using MS Visual studio 2010 and openCV 2.4.8.
I get the following error when I execute some project.
Suppose I have a solution which contains only 1 project. That was built by me.
And, I have one other solution created by someone else and there are 2 projects in it. Out of the 2 projects created by that person I chose one and I copied the required header files, cpp files, DLLS and everything and put them in my project.
Then I get the above error.
Both the projects works fine when executed separately. Have I made a mistake in copying ? Or else, is there something else behind this ?
to solve this problem you should copy the DLL files from the direction of opencv like C:\opencv\build\x64\vc12\bin to the debug or release file in the project files
The problem is due to 32/64-bit mismatches of various system dlls required by Visual studio. Somehow the dlls it needs got replaced by 64-bit versions that it couldn’t load.
Replacing the dlls mentioned below from a machine that is working, solves the problem:
c:\Windows\SysWOW64\msvcp100.dll
c:\Windows\SysWOW64\msvcp100d.dll
c:\Windows\SysWOW64\msvcr100.dll
c:\Windows\SysWOW64\msvcr100_clr0400.dll
c:\Windows\SysWOW64\msvcr100d.dll
The Application was unable to start correctly (0xc000007b). Click OK to close the application" when starting Visual Studio 2010
I've found another solution of this issue. In VS window you can just change the machine type from default 'Win32' to 64-bit (default 'x64').

Visual Studio error while trying to run project

I have the following scenario:
Visual Studio 2010 solution with one WPF-project, output file is "Tool.exe"
Eclipse Shared Library project, output file is "Tool.dll"
I place the dll in the same folder as the exe and then I try to debug using Visual Studio; but I get the following error:
Error while trying to run project: Could not load file or assembly 'Tool' or one of its dependencies. The module was expected to contain an assembly manifest.
I have managed to find a solution to the problem, rename the dll, apparently the exe and dll cannot have the same name. My question is, why is this error occuring in the first place? Why does the name of the dll affect Visual Studio? The error occurs before even trying to pinvoke the dll. If I run my application without Visual Studio it works perfectly, but I want to be able to debug it of course.
Right now renaming the dll is plan B, but before I do that I would like to know if there is anything else I can do to fix this problem?
Thanks in advance.
I found simple steps to solve this error.
1- change your windows.
2- install Symantec Endpoint Protection Client 12.1.6318.6100 x32 or x64 bit.
You can geting it software(32 bit) from link: (ftp://192.168.168.215/Public/Antivirus/Symantec/Symantec Endpoint Protection Client 12.1.6318.6100 x86.rar)
drag and drop it to your software(IE ,....) to work.
3- install all driver on your computer.
4- install Visual studio.
End

How to solve this error: Could not find file 'Microsoft.Windows.CommonLanguageRuntime, Version 2.0.50727.0'

This question to which I already found the answer is posted here in case of someone else encounters it. I decided to post the Q&A here so that SO has something about this error, since I don't know if it's been here before.
This occured after an update of the .NET Framework. Before the update, everything compiled just fine! After the update, I could compile nothing!
The error message is:
Error 1 - Could not find file 'Microsoft.Windows.CommonLanguageRuntime, Version=2.0.50727.0'.
This is a problem within Visual Studio 2005. This occurs after an update of the .NET Framework 2.0 and is due to project reference within a single solution.
For example, when you're writing a test library which will test your assembly within the same solution, you will most likely reference the project. Then, this error may occur.
To solve this error, simply reference the file binary of your project, either the DLL or the EXE within which resides the code you want to test. This is called a file reference.
Let's suppose we have two projects called:
Company.Project.ApplicationName;
Company.Project.ApplicationName.Tests.
When adding the reference to our Company.Project.ApplicationName project within our Company.Project.Application.Tests project, we can either use the Browse or the Project tab. When using the Project tab, you create a project reference. We don't want to use this if this error occurs. What we want to use is Browse, so that we can make a file reference.
Here's a link to the Microsoft Support Website that explains this issue.
You may receive a "Could not find file 'Microsoft.Windows.CommonLanguageRuntime" error message when you build a solution of a Visual Basic 2005 Windows Application project in Visual Studio 2005

Why do I get "An error occurred while validating. HRESULT = '80004005'" when building a setup project?

Why do I get the following error when building a setup project?
An error occurred while validating. HRESULT = '80004005'
One project in solution had ToolsVersion="4.0" (in .csproj file), changed it to ToolsVersion="3.5" and setup project builds fine.
Both of the reasons I found are already in other answers, but they are in separate answers and not fully explained. So, hopefully this will combine the possibilities and give good means of debugging each. :)
Common Reason
My problem was not a dependency error. However, that does seem to be the common reason. So, basically, you need to check your MSI file and make sure that all dependencies are still valid. Probably the best blog response on how you can easily resolve this if it is a dependency issue is An error occurred while validating. HRESULT = '80004005'.
Extract from blog:
Follow steps below to troubleshoot.
If you have multiple project outputs in your solution, identify the project that is giving the problem. You can do that by removing one project at a time from the Setup Project(S) until error goes away.
Once project is identified, identify the reference that could be giving the problem.
Check if the project(A) is referencing to a project that has been removed from solution. - Remove such references if any.
Check if the Project(A) is referencing to a project that was moved to a diffenrent physical location after it was added as a reference. - Remove and add such references.
Rebuild setup project after fixing the reference accordingly to see if error goes away.
Alternative Reason
My problem had to do with Visual Studio versioning, however. So, if your dependencies are valid and you still are getting this problem, then you resolve this if it is a problem with VS2010 .
Basically, if you run MSBuild and see this warning:
Project file contains ToolsVersion="4.0", which is not supported by
this version of MSBuild. Treating the project as if it had
ToolsVersion="3.5"
Then the problem is Visual Studio versioning. This means that one project was opened or created in Visual Studio 2010 and then saved or added to an existing 3.5 solution. I simply searched all files in my project for ToolsVersion="4.0" and found the offending .csproj file, opened it in a text editor and manually changed the 4.0 to a 3.5.
This error is related to a dependency error. I removed all references to my primary output project and added them again. It now compiles OK!
I ran up against this issue today. The solution in my case? Restart Visual Studio 2008.
In my case my solution (VS2008) had a project that was also referenced from another solution (VS2010). In the VS2010 solution I had upgraded the project to .NET 4.0. When I later realized the project was also used in another solution I downgraded it to .NET 3.5. For some reason everything seemed to be changed correctly in the csproj file except one place which is mentioned here: Error in setup project HRESULT = '80004005'
I know this is already solved somewhere else but I wanted to shed some light on this from another problem angle.
While simply removing and re-adding the project dependencies will work in many cases, it is important to note that:
The error message "An error occurred while validating. HRESULT=80004005."
usually happens when project is referenced to the other project which is
not added into the currect [sic] solution. Setup project only supports
dependency projects within same solution.1
I have spent enormous time on this one myself, though none of the above worked. But I have found another solution with a registry hack, you need to add a new DWORD (EnableOutOfProcBuild) value of (0) to HKCU\SOFTWARE\Microsoft\VisualStudio\14.0_Config\MSBuild\EnableOutOfProcBuild
Note: this is for Visual Studio 2015
In my case I had installed Visual Studio 2010 alongside Visual Studio 2008. My setup project, when opened in Visual Studio 2008 gave the same error, but was OK in Visual Studio 2010.
If copied to another machine that did not have Visual Studio 2010, but did have Visual Studio 2008, then it would compile.
I installed Visual Studio 2010 and converted the solutions to that version. Because of performance issues I changed my solutions back to Visual Studio 2008. Everything was better now but I got an error when I tried to compile the setup project. I realized that I had a Visual Studio 2010 Test Project in my solution so all I had to do was unload the Test Project and Build the setup project again.
Summary: unload any Visual Studio 2010 project in solution.
I hope it helps.
I know this is kinda old news, but my particular issue and solution are not specifically stated here (as far as I can tell - if I missed it, I apologize).
I had same problem. It would not compile my project, but had no errors. All I could see was "Build Failed". I opened up the "Output" file (Click View--> Output on menu), and it told me exactly which reference (in my case a .dll) was causing the problem.
I deleted and recreated the reference and it changed the reference name from Microsoft.Office.Core (which was appearently only a 32 bit version) to "OFFICE". Then everything worked great. -- Make sure to make a note of the path to the file you are referencing in the properties window... My new path was exactly the same, but the reference name changed anyway.... still scratching my head on that one...
So the moral of the story is... When you get no errors and your build fails, check the "Output" tab and it might help.
I read this answer from another post on Stack Overflow, and it has worked for me.
Open your setup project file (.vdproj) in Notepad (or any other text editor). Delete these lines at a beginning of the .vdproj file:
"SccProjectName" = "8:"
"SccLocalPath" = "8:"
"SccAuxPath" = "8:"
"SccProvider" = "8:"
Build again - the error is gone. That error didn't stop me from deploying, building, debugging (or anyting) my project; it just annoyed me. And it came on even if I set all projects to be build in a current configuration and the setup project not to.

Resources