Solving error MSB8011: Failed to register output - visual-studio-2010

A strange error:
error MSB8011: Failed to register output. Please try enabling Per-user
Redirection or register the component from a command prompt with
elevated permissions. C:\Program
Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets 744
I got this error when trying to use OpenSceneGraph (OSG) in an ActiveX control. A Google search showed all kinds of solutions which didn't really solve the problem or locate the exact cause of the error, so I'd like to put the solution in one place: Here.
I found the solution to it, and will be answering my own question soon, so that people can find their solution if they encounter the same problem.

This error happens when Visual Studio (2010) can't find the dependent dll files that are required by the program for creating the OCX. The OCX is created in the Debug directory of the project (for Debug builds), and specifying the "Working directory" (in project settings) as the folder where the dependent DLL's are, won't help Visual Studio in locating the DLL's.
Now the catch is (this is what makes it a headache to solve the problem) that sometimes, without Visual Studio being able to create the OCX, you won't be able to run Dependency Walker on the OCX. So you'll never figure out that the missing DLL's are the problem.
If you know which DLL's need to be placed in the Debug folder, just place them there, and the error will disappear.
If you don't know, and if your OCX didn't get created, then go to project settings > Linker > General > Register Output
and set the value to "No". This will create your OCX for you, but won't go through the process of registering it, which is when it needs the dependent DLL's.
Once you double-click the OCX and Dependency Walker shows you the missing DLL's with yellow circle icons, just place those DLL's in the same folder as the OCX, and your program will work fine. It's that simple.

The issue could be that your project tries to register a COM object, but there are not enough privileges to do that. On Windows 7 and 8 regsvr32 requires administrative permissions.
What you can do is the following. Create a shortcut on your desktop to C:\Windows\SysWOW64\cmd.exe (the 32-bit console). Right click, Properties -> Advanced -> check Run as administrator. Launch the shortcut, and make sure User Access Control pops up, and click Yes. Start building from this special console window.

I tried using run as "Administrator" VS 2015, it's able to solved the problem

MSB8011 seems to be a generic error raised whenever regsvr32 encounters a problem. In my case, regsvr32 exited with code 4 when Per-User Registration was set to "Yes", but the DLL I was building did not define a DllInstall entry point.

You can also do this via VS 2013 IDE by launching this IDE from program files shortcut, Select Visual Studio 2010/2013 and then right click and select run as administrator, after IDE launched, then open your solution file and build it, you will never get such errors because of regsrv32 DLL/COM registration

On the Property page go to
Configuration Properties->Build Events->Post-Build Event
you might be referring to it as a /Service. Modifying options as shown below could help.
Before modification:
After modification:

I fixed this in Visual Studio 2019 by going to "Properties -> Linker -> General -> Per-User Redirection" and setting it to True.

Related

Cannot run CMake executable with or without debugger under Visual Studio 2017: "Access is denied."

I'm attempting to run a program built with a CMake-generated solution file under Visual Studio 2017's debugger in order to debug a problem. However, whenever I try selecting Start Debugging or Start Without Debugging I get the following error popup.
Unable to start program
'E:\build\someprogram\build\x64\Debug\ALL_BUILD
Access is denied.
At first glance the problem sounded like the one described here. However, that bug was allegedly fixed in VS 2017 15.5, and I currently use 15.6.7. And the location of the compiled executable isn't on a RAM disk or network drive, but on a physical drive. And the error happens when running without a debugger also.
Also I wondered about whether or not the executable was not properly configured, since it looks like the error is related to the ALL_BUILD target, but in my CMakeLists.txt I have this declaration:
add_executable(someproject ${SOURCE_FILES})
I would think that would add the executable to run. It also appears as a subproject in the Solution Explorer.
The compiled .exe runs outside of Visual Studio fine, although it crashes, which I'm trying to debug. Strangely, I cannot enter the Visual Studio debugger from the Abort/Retry/Ignore dialogue that appears after the crash by clicking Retry like it instructs; the window for choosing the Visual Studio version never appears.
It does not seem to be a permissions issue since I manually adjusted the permission of all the build directories with all permissions, with no changes. I'm also running Visual Studio with administrator privileges, and it makes no difference. Additionally I replicated the build process on an entirely different machine (Windows 10, as opposed to Windows 7) and the exact same error occurs, so I'm suspecting it's a CMake issue.
You need to set a different project as startup project (right click on your target executable project "someproject" and select "Set as StartUp Project" from the context menu). ALL_BUILD is a symbolic target and is not connected to an executable.

Visual Studio - Error when clicking on Solution -> Properties (Object reference not set to an instance of an object)

When i try to access my solution Properties, i get the following error:
Object reference not set to an instance of an object
I am using VS 2012. What could be the cause of this?
Some extensions may cause this.
Try disabling extensions and restarting Visual Studio.
Quite often error will be gone even if you re-enable extensions after this.
There's a bug report on Microsoft Connect (link).
It is marked there as "Closed as External", but it seems that it may occur randomly with any extension, so would be worth voting it there to bring it to Microsofts attention.
In my case, the problem was solution-specific. NuGet was causing this error, but not the extension itself but a NuGet package that generated an error on VS load. When I opened NuGet Package Manager Console I saw a big red text with a description of the error. In my case it was T4Scaffolding.Core package, which in turn is a dependency of MVCMailer.
If this is your case, you will probably see what package generates an error in PM Console.
I faced this dialog too and i'm not sure what exactly causes this as i couldn't even open the NuGet console to see detailed error messages.
Closing Visual Studio, deleting %AppData%\Microsoft\VisualStudio and restarting Visual Studio worked for me as it causes a reset of various things like window configurations.
I think if this dialog is displayed some files may be corrupt in %AppData%\Microsoft\VisualStudio and by deleting that folder Visual Studio can start normally again.
Update:
The issue arises on my machine when i start Visual Studio by using "run as administator" whereas Visual Studio has been started before without that option and %AppData%\Microsoft\VisualStudio had been created without the administator association.
Visual Studio 2013: I had this issue when I tried opening TOOLS -> Extensions and Updates.
I used #ViRuSTriNiTy idea, but only cleaned the files from:
C:\Users[myUserName]\AppData\Local\Microsoft\VisualStudio\12.0\Extensions
There are 2 cache files over there.
Deleted them and restarted VS2013 and it was fixed
The way it was happening for me might be unique to me/my setup, but I'd love to know if anyone else has this happen, and if they find out why:
If I launch an .sln file by double-clicking it, it will load VS and I can right-click the Solution and get Properties to come up no problem.
If I go to "Open Project" on the Visual Studio welcome page or from File > Open > Project/Solution, navigate to the .sln file and launch it by selecting it and clicking "Open" in the File dialog, that's when I have this issue.
I'm going to just always launch the .sln file from now on, but I'd love to know why this happens when using "Open Project" from the welcome page or from File > Open > Project/Solution! I tried going into Tools > NuGet Package Manager > General and I unchecked the options for allowing NuGet to download missing packages and Skip applying binding redirects, and under Package Sources I de-selected the checkboxes (my dev machine does not connect to the internet). Environment > Extensions and Updates: I tried it with and without "Load per user extensions when running as administrator" and running it as an Admin and without running as Admin. Also tried just deleting everything at C:\Users\me\AppData\Local\Microsoft\VisualStudio. No change from those 2 bullets above.

cannot create any C++ project

I have Visual Studio 2010 Ultimate on Windows 7 Enterprise running on a x86 box. I cannot create any C++ project from VS although I can create C# project. On the new project dialog I press OK button and nothing happens. I don't get any error but no solution or project is created either. Not sure if it helps but I log in as Administrator. Any ideas?
Did you check the thing called C++ runtimes which is required by VS to run properly?
I guess the idea to reinstall is good.
This will even repair some missing or corrupt which may have been accidentally deleted or corrupted.
Most probably you did not check the C++ language option during installation. If you re-run the Visual Studio installer and check the C++ language option (maybe choose custom setup to make sure you see the option and are able to include it), everything will run file.
In case you already did that, there might be a problem with the C++ project type registration in VS. Please come back to this forum if you still have problems after re-installation.

Visual Studio 2005 - Debugger stopped working

More fun and pain with Visual Studio. Visual Studio 2005.
About two months ago, I started an assignment. In my role, I cannot install or configure development software. Trust me this has given me plenty of heartburn. No IIS is involved here, just File Sharing.
That being said, when I first started I had a problem with my debugger not working. The debugger just stopped. I was able to get it working. Now the problem has returned and I am pulling every last hair on my head.
Almost none of my symbols loads. It can't find the PDB files.
In Debugger options, I checked the Symbol section.
My symbol file location entry is completely blank. ? I don't know why. I did not touch this prior to the problem occurring.
I have cleared the Temporary ASP.NET folders.
Example:
Here is my Module Output
CppCodeProvider.dll C:\Windows\assembly\GAC_MSIL\CppCodeProvider\8.0.0.0__b03f5f7f11d50a3a\CppCodeProvider.dll No No Cannot find or open the PDB file. 17 8.0.50727.762 12/2/2006 4:23 AM 6A510000-6A52C000 [1844] WebDev.WebServer.EXE: Managed
WebDev.WebHost.dll C:\Windows\assembly\GAC_32\WebDev.WebHost\8.0.0.0__b03f5f7f11d50a3a\WebDev.WebHost.dll No No Cannot find or open the PDB file. 3 8.0.50727.42 9/23/2005 4:20 AM 6D040000-6D050000 [1844] WebDev.WebServer.EXE: Managed
So I enabled the SHFUSION.dll in my versio of the the Framework I am using...
In my GAC, I can see this version of WebDev.WebHost.dll for example:
ProcessArchitecture(x86)
Public key token matches:
b03f5f7f11d50a3a
8.0.50727.42
I then see some custom dlls.
I should note, I created a new project. Recreated my files manually by importing them. The debugger worked 5 times and died.
I'm at a loss of what to do next?
The obvious has been checked: The project is set to Debug
Configuration Manager Configuration Debug Platform .NET Build : checked.
Web.Config:
I have attempted to manually attach to the Webdev process from the Debug window and that doesn't work.
I have googled this and this problem seems to occur quite a bit.
You mentioned that your symbol server settings are blank. Have you tried adding the Microsoft Symbol Server location?
Go to Tools -> Options -> Debugging -> Symbols
Add the following to the symbol file locations:
http://msdl.microsoft.com/download/symbols
You can also use this to point to more symbol locations. For instance, if you have a directory for all of the debugging symbols for your software, you could place the .pdb files there and add the directory to Visual Studio to load them.
Pick a directory for the symbols to save to and try again.
Yesterday, I reset my environment variables on my laptop from
VS2005 prompt, blew away the Temporary ASP.NET files and I was debugging again.
After 4 rounds of debugging it quit again. I cleaned the folders again, and I was debugging again.
It get's better. They replaced laptop today with a desktop.
I no longer have admin priviledges. A lot of common troubleshooting
steps are now off the table ( i.e. cleaning Temporary ASP.NET folders, installing
new symbols from MS site.)
Get this, first thing I did was download the code from our Subversion repository.
Built it. I was able to debug it 1 time.
I made some changes based on the problem I'm working on. 2nd time, debugger would not work.
I've been neutered as well as having to deal with this problem. Isn't life grand.
I'm beginning to wonder if the issue is not related to some folder permission/configuration of my account on the network. But I'm also considering a wide variety of tin foil hats as I pull out my hair. . .
Thanks for your help....
Visual Studio is probably installed in %ProgramFiles%. On Windows 7 or higher, you will need administrator rights to use programs like Visual Studio. Companies should trust their developers enough to give them accounts with Administrator rights.
If you're in the unfortunate situation of not having Administrator rights, you may be able to add the following registry key (or ask your IT department to add this key manually for you). Be sure to check that your Visual Studio 2005 installation path in the .reg file is correct.
Windows Registry Editor Version 5.00
; Run Visual Studio 2005 with administrator rights
; This is required to run / debug the program directly from the IDE
[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files (x86)\\Microsoft Visual Studio 8\\Common7\\IDE\\devenv.exe"="~ RUNASADMIN"

A project with output type of class library cannot be started directly - with a startup exe

Firstly I'm completely aware of this message and why it happens normally. It's not that I'm just trying to run a dll (like this question).
I have a project that compiles to a dll but has a startup program specified in the project properties. Most of the time I'm able to right-click on the project and select Debug > Start new instance, and it will run the program and let me debug my dll. However, occasionally I get this message (A project with output type of class library cannot be started directly) as if I haven't got a startup program. The first few times I thought it was just me accidentally clicking on the wrong project but I'm certain this isn't the case given that it's happened so many times and I've been careful to watch it.
When this message appears I'm able to try it again and it always works on the second or third attempt.
A colleague using the same Solution never has this problem :-/
Anyone else had this problem or know how to solve it?
I'm using Visual Studio 2005 Pro Version 8.0.50727.762 (SP.050727-7600)
Edit: Also happens with Visual Studio 2010
Another colleague suggested it's because after clicking Debug > Start new instance, while I'm waiting for it to start up, I click on a different project. I don't do it for any reason, just randomly selecting things as I wait for the project to start up. Maybe Visual Studio looks at the selected project sometime after I clicked the menu, gets confused, and shows the error message?
Anyone able to confirm this matches their experience?
Typically problems in VS are caused by:
Add-ins: Run VS without and see if the problems is solved
Corrupted files in your solution: Delete / rename all files created by Visual Studio which are not part of your project, i.e. all .suo, .ncb files and a like.
I had this problem with projects that were created as "Windows Control Library" that somehow forget their status. Unloading and reloading the project usually did the trick.
If it was created as a "Class Library" then to make it a "Windows Control Library" I manually add the following to the .csproj file. It was the only difference I could see between a class library and windows control library project.
BTW - starting a Windows Control Library starts the User Control Test Container - allows you to test any user control in the library. Very cool.
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
add that inside of an <itemgroup> element.
If you plan to use/create/add extra dll's or just have more than one project in your solution, you may get this kind of problem, especially if you forgot a simple rule:
1. In your "Solution Explorer" window. Right click and chose "Set StartUp Projects..."
2. Under "Start Up Project" select and change "Single startup project" to your working entity.
no just make a start up project
Going to resurrect this thread, I have just been experiencing similar issues, when right clicking a project and start new instance..
So instead of right clicking the project and selecting start new instance, I right clicked and clicked set as startup project.
Low and behold a class library project was set to bold, certainly not the one I was right clicking.
I tried selecting a different executable project and setting that as the startup project. Same class library was highlighted as the start up project.
Realised that the current open file was from that project, possibly all the open files were from that project...
closed all open files and tried again.... Problem solved, behaviour as expected for both set as start up project and start new instance options...
Definitely a bug, hope this helps others..
Microsoft Visual Studio 2010 Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework Version 4.0.30319 SP1Rel
This sounds like a transient Visual Studio problem. Reinstallation or upgrade may solve your problem.
I've seen this as well, and it seems like a bug in VS. It happens after you right-click/build a class library (that requires rebuilding), and then right-click/debug > start new instance.
edit- It's still very intermittent, I can't seem reproduce it reliably
I've found that I've had the Startup Project on the Solution set to Current selection, then at some point, I've unloaded a project, and the solution has reverted to Single startup project on a project that happens to be a class library.

Resources