Visual Studio Development Bookmark and Share   
 index > Visual Studio Tools for Office > Error when trying to run simple Excel app
 

Error when trying to run simple Excel app

Hello,

I'm trying VSTO for the first time having built Office apps in VBA for a while and knowing C#.  I'm trying to rebuild an Excel app in VSTO, but I can't even get the most simple of  to work.  Everytime I hit F5 I get the message: "The customization assembly could not be found or could not be loaded."  I've searched around loads and read lots about trust settings, manifests and assemblies, but got absolutely nowhere with getting an app to run.

Can anyone help me?

Cheers,

Ollie.
Ollie Purkiss  Thursday, October 15, 2009 8:10 PM
Hi Ollie

We need a bit more information from you:

1. Version of Visual Studio (including information such as "Standard", "Professional", "TEam Suite")?

2. Version of Office?

3. What Visual Studio template did you start with in the File/New dialog box? (Folder path and template name)
Cindy Meister, VSTO/Word MVP
Cindy Meister  Friday, October 16, 2009 6:47 AM
Hello Cindy,

Thanks for replying.

Answers to your questions:

1. 2008 Professional

2. 2007 SP2 MSO

3. Excel 2007 Workbook

I have got a little further with this, when I came in this morning.  I turned on breaking on "Common Language Runtime Exceptions", and the following exception gets thrown when I try to debug:

A first chance exception of type 'System.Deployment.Application.DeploymentException' occurred in System.Deployment.dll

Additional information: Store metadata "CurrentBind" is not valid.

Ollie Purkiss  Friday, October 16, 2009 9:23 AM
I've got even further with this.

I've narrowed it down to my use of a Dictionary<>.  If I comment out the call to Add on the Dictionary then it works, otherwise the exception gets thrown.  Something to do with .NET versions?

Ollie.
Ollie Purkiss  Friday, October 16, 2009 10:50 AM
Hi Ollie

Could you show us the line of code, please?

And have you searched the Microsoft site for this error message, to see if there's anything in the Knowledge Base? (I'd look, but I have to run...)
Cindy Meister, VSTO/Word MVP
Cindy Meister  Friday, October 16, 2009 10:59 AM
Hello,

I've now got passed this problem, but I'm still a bit bemused.

The line I was talking about had an error on it - I was trying to use a null object reference (idiot), so that was why the customization assembly was failing and that makes perfect sense.  The strange thing is that when I turned on "Common Language Runtime Exceptions" to try and see why it wasn't working I had two other unrelated exceptions come up before the exception relating to my code.  These exceptions are:

A first chance exception of type 'System.Deployment.Application.DeploymentException' occurred in System.Deployment.dll

Additional information: Store metadata "CurrentBind" is not valid.


and:

A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: Could not find file 'C:\Program Files\Microsoft Office\Office12\Excel.exe.config'.


But it turns out that these are always coming up and I can continue past these exceptions and it all seems to work fine. The two things I'm confused about are:

  • What are those exceptions and do I need to worry about them?
  • When I didn't have "Common Language Runtime Exceptions" turned on, why did the exception in my code not have any of my code in the call stack and offer me no option to debug it?
With the second question, if I break and step over the problem line then it brings up a "Break / Continue" box as I'd expect, but not if I just run the program and it crashed in Excel.  Is that what's meant to happen?

Ollie.
Ollie Purkiss  Friday, October 16, 2009 4:49 PM

Hello Ollie,

It seems like you have got the solution for this issue as using a null object.

To the first question, it does not represent that there are some problem in your code. In this blog article, here I quote a message. When an application is being debugged, the debugger gets notified whenever an exception is encountered At this point, the application is suspended and the debugger decides how to handle the exception. The first pass through this mechanism is called a "first chance" exception. Depending on the debugger's configuration, it will either resume the application and pass the exception on or it will leave the application suspended and enter debug mode. If the application handles the exception, it continues to run normally.

To the second question, I am afraid it is little related to VSTO technology rather than Visual Studio. However, I think it is by design issue. I also recommend you post such an issue to Visual Studio Debugger forum, where there are more Visual Studio specialists, and you would probably get more helps. Here is the link: http://social.msdn.microsoft.com/Forums/en-US/vsdebug/threads.

Best regards,
Bessie


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Bessie Zhao  20 hours 29 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• Outlook 2003 addin installation problem
• Disappearing Document ActionTask Panes with Word
• Commandbuttons shortcuts not working.
• Regaining control of Excel spreadsheet from VB.net
• ClickOnce API CheckForDetailedUpdate not working for VSTO?
• Outlook2003 Categories list
• Word SaveAs MailMerge - 1. Extra Page, 2. Retains Data Source
• Replacing sentences in a word document: Carriage return / NewLine problem
• Merge styles in Excel (office interop and C#)
• Word - Property for print setup