views:

307

answers:

1

I'm trying to develop an AddIn for Excel 2007, and have a solution full of code that executes and debugs just fine on other people's machines. When I try and Start Debugging in Visual Studio on my machine though, Excel gives me an error when it loads my AddIn:

"An AddIn could not be found or located."

I then click on the Details button to see the stack trace:

Cannot access a disposed object.


************** Exception Text **************
System.ObjectDisposedException: Cannot access a disposed object.
   at Microsoft.Office.Tools.SmartTagCollection.BeginInit()
   at ExcelAddIn1.ThisAddIn.BeginInitialization() in C:\Documents and Settings\james.cox\My Documents\Visual Studio 2008\Projects\ExcelAddIn1\ExcelAddIn1\ThisAddIn.Designer.cs:line 129
   at ExcelAddIn1.ThisAddIn.InitializeDataBindings() in C:\Documents and Settings\james.cox\My Documents\Visual Studio 2008\Projects\ExcelAddIn1\ExcelAddIn1\ThisAddIn.Designer.cs:line 66
   at Microsoft.VisualStudio.Tools.Office.EntryPointComponentBase.Microsoft.VisualStudio.Tools.Applications.Runtime.IEntryPoint.InitializeDataBindings()
   at Microsoft.VisualStudio.Tools.Applications.AddInAdapter.ExecutePhase(ExecutionPhases executionPhases)
   at Microsoft.VisualStudio.Tools.Office.Internal.OfficeAddInAdapter.InitializeEntryPointsHelper()

I actually have now created a brand new solution of type Excel AddIn, and not changed anything in the code at all, and still get the same error.

What does this mean? Googling around, I see someone on MSDN who seems to have had the same issue but unfortunately never got an answer to his questions. Has anyone seen this issue before?

+2  A: 

I encountered the same problem tonight when trying to test out the RibbonX features in Excel 2007. I noticed that in the exception message there was a referal to SmartTags, so I pulled up Control Panel and changed my installation of Office to not include Smart Tag .NET Progammability support, under Office Tools in the Customise installation window. After this my addin ran without problems.

It may also be possible to remove the problem by doing a removing mention of Smart Tags from the addin. I believe this can be done by editing the Designer files for the ThisAddIn.cs file, these can be made visible by using the Project, Show All Files option in Visual Studio.

In ThisAddIn.Designer.xml you should remove the following line:

<hostitem:hostControl hostitem:name="VstoSmartTags" hostitem:identifier="VstoSmartTags" hostitem:type="Microsoft.Office.Tools.SmartTagCollection" hostitem:primaryCookie="VstoSmartTags" hostitem:modifier="Internal" />

And then remove any references to VstoSmartTags in the ThisAddIn.Designer.cs file. Word of warning though, I haven't actually tried this out so it may not work.

MattF
That did it! Thanks very much; maybe one day we'll find out what actually causes the problem on some comfpiuters and not others...
Coxy
Great, maybe it'll help someone else some day too!For future reference, seems like the first option of uninstalling the Smart Tag support didn't continue to work correctly so I went with the second option, which definitely cured the problem.
MattF
impressive. that did the trick for me, too.
Sebastian Good