Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solving error MSB8011: Failed to register output

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.

like image 860
Nav Avatar asked May 07 '12 05:05

Nav


7 Answers

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.

like image 77
Nav Avatar answered Nov 16 '22 03:11

Nav


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

like image 20
EW28x021 Avatar answered Nov 16 '22 03:11

EW28x021


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.

like image 8
Tamas Demjen Avatar answered Nov 16 '22 03:11

Tamas Demjen


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.

like image 3
Mike Avatar answered Nov 16 '22 04:11

Mike


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

like image 2
Suresh Avatar answered Nov 16 '22 03:11

Suresh


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:

Before modification

After modification:

After modification

like image 1
Stephen Philip Avatar answered Nov 16 '22 03:11

Stephen Philip


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

like image 1
DJMcMayhem Avatar answered Nov 16 '22 05:11

DJMcMayhem