1

I am trying to create an excel add-in using Visual Studio 2013. The add-in is for Excel 2010.

Now the issue I am facing... I am not able to run the add-in in debug mode. When I click "Start" to debug my code, Excel opens and closes immediately. This issue does not have anything to do with my project, because the issue happens even when I create a fresh add-in project without any code.

The following message is displayed in the output window.

'excel.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Symbols loaded.
The program '[10116] excel.exe: Program Trace' has exited with code 0 (0x0).
The program '[10116] excel.exe' has exited with code -2146233082 (0x80131506).
Community
  • 1
  • 1
Kannan Suresh
  • 4,573
  • 3
  • 34
  • 59

3 Answers3

2

Try opening Excel first instead of using 'Start' to debug, then from your Visual Studio solution click on the Debug menu > 'Attach to Process' and select EXCEL.EXE from the list of available processes.

This works for me as I also have the Office app quit on me when using 'Start'

Oliver Gray
  • 874
  • 6
  • 17
0

Symptom:
In Visual Studio, Debugging (F5) a VSTO Add-In launches Excel and then the Excel process crashes.

Solution:
Create an XML file called Excel.Exe.Config:

<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v1.1.4322"/>
<supportedRuntime version="v1.0.3705"/>
</startup>
</configuration>

The versions must match what you find in C:\Windows\Microsoft.Net\Framework.

Place Excel.Exe.Config in the folder that contains Excel.exe, eg:C:\program files\Microsoft Office\Office14

If using .Net 2 resolves the problem you can narrow it down to .Net 4.5 by seeing if .Net 4 will work, eg:

<supportedRuntime version="v4.0.30319"/>

If the above doesn't work please enable VSTO logging as I discuss here (#7) and is detailed in depth here and add those details to your question.


Edit:

  1. I have this vague memory of something similar happening to me, I should have documented it - make sure the Office VSTO Runtime installed on the PC?

  2. You don't have multiple versions of Office installed do you? That is not supported as per: http://blogs.msdn.com/b/andreww/archive/2007/06/08/why-is-vs-development-not-supported-with-multiple-versions-of-office.aspx

  3. Try it on another PC? Does it work - if so its PC specific and you should do a repair &/or uninstall/reinstall of Office and Visual Studio

  4. Make sure you can debug other applications like winform app? And you can debug a Word or Outlook Add-In?

  5. It's a long shot (and I understand its Visio not Excel) but is EMET installed: https://social.msdn.microsoft.com/Forums/vstudio/en-US/c259df5b-d76c-4de4-86c9-6690522cd9b8/visio-crashes-when-debugging-addin-in-visual-studio?forum=vsto

  6. If the above fail more in depth troubleshooting is required. Setup Adplus to take a Crash using the -pn switch set to Excel. Reproduce the problem then open the Memory Dump in windbg and issue a !analyze command.

Community
  • 1
  • 1
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • Tried it, but did not work. In addition VSTO logging also doesn't work for me. Added the environment variables, no messages shown and cannot find the file .manifest.log – Kannan Suresh Feb 09 '15 at 06:59
  • No VSTO messages logged? Hmm thats weird. a) Please double check [you have it setup correctly](http://www.macroview.com.au/support/KnowledgeBase/Pages/20110084.aspx), b) Hook up these two events: System.Windows.Forms.Application.ThreadException and AppDomain.CurrentDomain.UnhandledException, c) You are running Visual Studio as an Admin right? and d) Does it work if you start Excel and then attach a debugger to the Excel process? – Jeremy Thompson Feb 09 '15 at 08:01
  • a. Yes, I did it correctly. b. Not sure how to do it. c. Yes. d. No – Kannan Suresh Feb 09 '15 at 08:42
  • 1. VSTO Runtime is installed. 2. I have only Office 2010 installed. 3. Issue is present on all machines at my office. 4. I can debug other applications like winform but not addins. Same issue for Outlook and Word. 5. EMET is not installed. 6. Will try. – Kannan Suresh Feb 11 '15 at 13:03
  • Any luck? or any closer to the last resort (memory dump)? – Jeremy Thompson Feb 12 '15 at 10:08
-2

Check the project target framework may be project is targeting .Net framework 4.5 try changing target framework to .Net framework 4

https://social.msdn.microsoft.com/forums/vstudio/en-US/14a645f3-4ecd-4815-9fdd-eb2756b70945/net-45-office-2010-addin

pubudut
  • 603
  • 2
  • 8
  • 18