Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SharePoint 2010 Debug Client Side Code Hooking IE

Posted on 2012-03-23
10
Medium Priority
?
369 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 2000 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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 2000 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

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

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

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

670 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