My First round of debugging
Figuring that it would be wise to debug the code so far before moving on to the next module, I fired up F5 and let ‘er rip:
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
at Microsoft.Office.Core.CommandBarsClass.get_Item(Object Index)
at Word2MediaWiki__.ThisAddIn.ThisAddIn_Startup(Object sender, EventArgs e) in C:\Documents and Settings\msmithlo\My Documents\personal\VS2005 Projects\Word2MediaWiki++\Word2MediaWiki++\ThisAddIn.vb:line 11
at Word2MediaWiki__.ThisAddIn.FinishInitialization() in C:\Documents and Settings\msmithlo\My Documents\personal\VS2005 Projects\Word2MediaWiki++\Word2MediaWiki++\ThisAddIn.Designer.vb:line 65
at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecutePhase(String methodName)
************** Loaded Assemblies **************
That sure didn’t take long. .NET is barfing on the following statement:
Dim MyControl As Microsoft.Office.Core.CommandBarControl = Application.CommandBars(W2MWPPBar).FindControl(Microsoft.Office.Core.MsoControlType.msoControlButton, Tag:="W2MWPP Convert")
I’m not entirely sure where the “type mismatch” is coming from, but given that this is a command directly ported from VBA, it’s probably safe to assume there’s a different/better approach in VB.NET. [If I had to guess, however, I’d think that the MyControl can’t be equated to Application.CommandBars() when it’s just been declared As Microsoft.Office.Core.CommandBarControl – there’s something about casting Application.CommandBars to Office.CommandBars that tells me “Application” and “Office” just can’t be equated like that. I really wish I knew exactly why, but someday I’m sure I’ll look back and wonder why I didn’t “get” it.]
Based on my experience with a previous Word VSTO add-in, I tried Office.CommandBarButton rather than CommandBarControl, and I think I’ll rework some of the logic to parallel the way that I’d made this same Bar + Button construction work in the past.
I’ve let this task sit for a few days while I debate with myself the merits of (a) making as little syntactic as well as functional changes to the code as humanly possible, (b) replacing whole swaths of code with stuff I know that “works” — even if I’m not convinced that the replacement code is any more “elegant” or performant than the stuff I’m replacing, or (c) bashing my head against a wall with a few attempts at [a] until I confirm that I won’t be able to figure it out easily, at which point I revert to [b].
I was originally inclined towards [a], so that I didn’t offend the original author and I didn’t act like some impatient arrogant twit who thinks that “they know better”. However, the longer I stall on any piece of code for which I don’t have a clear idea which specific calls, variables or syntax is causing the incompatibility — though I feel I understand its overall function — the more I’m getting to the point that I’d rather put out something that works than spend another six months trying to be as surgically precise as possible in my upgrade.
I guess the most important thing is to document (a) what I’m replacing, (b) how I expect the replacement code should work/should accomplish the same thing, and (c) use as many of the same variable names as possible so that anyone familiar with the old code would have the best chance of understanding the new code as well.
So my thinking is, I’ll try to preserve the variable names, and as much of the overall logic as possible, but that I’ll replace any non-functioning code with whatever I know (or can find online) that works so that this project doesn’t get permanently stalled (which is a serious risk with me).
Response to Redistribution Request for Wikifunctions.dll
The whole loosely organized nature of open source means that you might never get a straight answer to any question, but I did receive a response to my inquiry about whether it would be acceptable to redistribute the compiled binary of Wikifunctions.dll. The response indicated,
“No problem if you include the binary you downloaded yourself. Don’t forget, it’s copyleft. Of course, you’ll have to honor GPL by mentioning that “this software includes parts from AWB developed by blah blah blah…”. Be advised though that WikiFunctions is designed primarily for AWB and thus has some limitations such as requirement for approval to be able to edit pages. Probably you will find something else more useful. For example, WikiAccess (with docs in Russian, hehe).”
Join us again… well, you know the drill by now…