Solved

SharePoint 2010 Debug Client Side Code Hooking IE

Posted on 2012-03-23
10
360 Views
Last Modified: 2013-11-26
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.
0
Comment
Question by:Howard Bash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
10 Comments
 
LVL 15

Expert Comment

by:colly92002
ID: 37756889
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
 
LVL 1

Author Comment

by:Howard Bash
ID: 37756911
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
 
LVL 15

Assisted Solution

by:colly92002
colly92002 earned 500 total points
ID: 37756932
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Howard Bash
ID: 37757123
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
 
LVL 15

Accepted Solution

by:
colly92002 earned 500 total points
ID: 37757684
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
 
LVL 1

Author Comment

by:Howard Bash
ID: 37793111
The suggested URL doesn't seem to address how to hook into the code in debug.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question