These DLLs are not added to my project in prior versions of Visual Studio. My guess is that one of my references has a dependency to these DLLs. From what I've read, the highlighted Microsoft.Office.Interop.Excel
might be the one. Can anyone confirm this? I should also note that VS 2015 always publishes these DLLs as well even if I exclude them from the the project. If I delete them, VS 2015 will remake them.
Edit: I have confirmed that the Excel and Office references are what's causing the inclusion of stdole.dll. See selected answer below to remove stdole.dll.
I've crossed out the custom references. Let me know if more information is needed. Here's my current references:
I have been dealing with this problem for ages.
Whenever I install anything from the web platform or any updates the stdole.dll gets replaced with a non signed version. I reported the bug to Microsoft a while back but fell on deaf ears.
I go to C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies and copy the signed version (22kb) from here and replace the version in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Visual Studio Tools for Office\PIA\Common (16kb) and that solves the problem.
Scott
As others indicated,
stdole.dll
is a Primary Interop Assembly for a bunch of Office COM interop components. You can determine why it's getting included in your project by doing the following.In Visual Studio, go to
Tools > Options > Projects and Solutions > Build and Run
. Change the "MSBuild project build output verbosity" setting toDetailed
. Now clean and rebuild your project.Open the Output window and search for
stdole
. You should find a section like this:You can see where Visual Studio searched for the assembly as well what requires it at the bottom. In my case it's a bunch of old Crystal Reports assemblies.
Sometimes you can embed the interop types via the dependencies as Tony suggests, but not always. For me, the Crystal Reports assemblies do not support this.
I fixed this problem (and the insidious one scottsanpedro mentioned) by copying the
stdole.dll
(32KB, digitally signed) fromC:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\
into a "Dependencies" folder inside my project. I added the file to my project and added an explicit reference to it (Add Reference > Browse). Finally I opened the new reference's properties and setEmbed Interop Types
toTrue
.This seems to be a better situation. I shouldn't need to worry about getting an unsigned version of the assembly.
If you have the option, use Embed Interop Types and leave stdole.dll out of it all together or you will run into the problem every time you move the application (new servers or dev machines) where stdole.dll isn't signed.
Problem: There is a reference that is requiring stdole.dll and stdole.dll is now being automatically pushed to the bin folder.
Solution:
How to find the reference: When you click on the properties of your references, check to see if "Embed Interop Types" is set to false. To dig even further, Nick's answer has some great info.
References I've confirmed so far that use stdole.dll (probably more office programs as well)
Office
Excel
Core
Crystal Reports (Thanks Lithium. As Nick points out, you may not have the advantage of setting
Embed Interop Types=true
)If you find more, add them to this list or note them in the comments and I'll do it.
Hans Passant strongly discourages setting
Embed Interop Types=false
here: What's the difference setting Embed Interop Types true and false in Visual Studio?Scott Hanselman also talks about what the "Embed Interop Types" does here: http://www.hanselman.com/blog/CLRAndDLRAndBCLOhMyWhirlwindTourAroundNET4AndVisualStudio2010Beta1.aspx
In my situation I found that toggling the Copy Local property of the assembly that depends on stdole.dll, saving the project and then toggling the property back to its original value, and finally saving the project again solved the problem. This property may also be related to the Embed Interop Types property for other people with this problem.
What this does is explicitly saves the Copy Local property to the .xxproj file. Otherwise, the state of this property is not in the project file and a default is assumed. I have no explanation why this works as the presence of the property in the project file does not change the displayed value in Visual Studio nor does it cause a change in the assembly actually being published or not. I also did not cause a change in these properties from their originally displayed values after toggling them back and forth.
I do note that even before I found the cure I saw that cleaning the project and rebuilding it did not cause stdole.dll to be copied to bin. It was only after publishing that stdole.dll showed up.