SharePoint 2010 Debug Client Side Code Hooking IE

I need to have the click of a word document from within IE breakpoint within some VSTO code.  In the past I had done something similar with finding the running IE process and associating that process with some code and indeed was able to break point within the code triggered by clicking a link in IE.

However,  the details of this technique and its applicability for breaking within a VSTO word add in is unclear.

Please advise / point to article(s).

Thanks.
LVL 1
Howard BashSenior Software EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

colly92002Commented:
I'm not clear as to what you want to do here.   When you click on a link to a Word doc in a document library, you are actually running some Sharepoint javascript code which checkes the document type, then checks the status (checked in, approved etc) and then if applciavble gives you teh option to check out the file and edit it.  At this point, Word has not been launched, so VSTO is not rellevant.

Once this has processed, Word is launched, and you  therefore could break the VSTO code here.

If you are running Sharepoint in IE on your dev machine, then Word should have your VSTO code deployed to it here, so add this in the ThisAddIn.cs  class of the VSTO code:
System.Diagnostics.Debugger.Break();

If it is a problem with a deployed version of the VSTO, then the above line will break the code, and you should be able to attach to the process in the normal way (although I have never tried this).
0
Howard BashSenior Software EngineerAuthor Commented:
When the link is clicked and word eventually is launched,  I want word launched but to breakpoint in code within my VSO Word ribbon add in load event.  So,  are you suggesting I put the System.Diagnostics.Debugger.Break() in my ribbon load event and that will cause it to launch VS2010 and break at that point?

Also,  I find that once I run the add in in the IDE,  it is installed without running any install code.  I can go into add/remove programs and uninstall and remove it from Word Com-addins and once I run the code in the IDE it is re-installed.  This seems to me to be a bug.
0
colly92002Commented:
Yes add it to the code and run on your dev machine and it should lauch VS.

Your VSTO addin will sit in Word until you remove it and this is why I was confiused, as a break in your code should jump to the debugger if it is open and you have just debugged it (which installs it on the dev machine).  This catches out everytbody I think (it certainly did to me when I first created one!).  You should remove it in code on your close event (ThisAddIn_Shutdown).  IIRC the MS examples all do this.  I also check at load and remove it there if it exists.

I've just looked at one I created which adds a menu bar (this is Word 2003 but should still relevant although teh events might have changed) and I have a method for removing it, and another for creating it, and I call them on this events:
private void App_DocChangeEvent()
        {
            RemoveMenubar();
            AddMenuBar();
        }
        private void App_DocOpenEvent(Word.Document Doc)
        {
            RemoveMenubar();
            AddMenuBar();
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
            // Remove the menu bar
            RemoveMenubar();

        }

Open in new window

0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Howard BashSenior Software EngineerAuthor Commented:
The word ribbon add in code does not have document open or document change.  Also, I'm not catching why you'd put code in an add-in that removes itself from the add-ins when the document/word closes.  Wouldn't that require reinstalling it next time  you would want to use it?
0
colly92002Commented:
As I said the example I give is from an office 2003 project - it may have changed completely!

When you add a customisation to the menu in 2003 (and I am presuming the Ribbon in 2010) this sits in your local customisation cache (Normal.dot).  The actual VSTO code is in a dll hooked up in the registry.  Because you are on a dev machine, the dll is always available, and when it runs it the first thing it does is adds the customisations to the menu   and this is recorded in normal.dot.  If you don't remove it when you exit, and check before you add it again on startup (in case the previous run crashed out rather than cleaning up) the next time you run it you will get two menus etc.  That is certainly how it works in 2003. It is possible that this has been completely changed in 2010, I don't know, so please don't le me confuse you, it just seems that the behaviour you describe seems reasonable to me.

Just try the walkthrough here:
http://msdn.microsoft.com/en-US/library/aa942955%28v=vs.80%29.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Howard BashSenior Software EngineerAuthor Commented:
The suggested URL doesn't seem to address how to hook into the code in debug.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.