Build 238/Excel2007: [TargetException]: Object does not match target type.

Jun 13, 2013 at 10:09 PM

Problem experienced in Excel 2007 under XP when trying to generate graph metrics. Running the 238 build. I did this with a new vanilla set of data and tried various combinations of options in the metrics dialog, but it seems to fail for everything.

NodeXL

Details:
[TargetException]: Object does not match target type.


Server stack trace:

at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)

at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)

at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)

at Microsoft.VisualStudio.Tools.Applications.InteropProxyImpl.OnImportedMethodInvoked(MethodInfo methodInfo, Object[] args, Exception& exception)



Exception rethrown at [0]:

at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

at Microsoft.Office.Interop.Excel._Workbook.get_Sheets()

at Smrf.AppLib.ExcelUtil.TryGetWorksheet(Workbook workbook, String worksheetName, Worksheet& worksheet)

at Smrf.AppLib.ExcelTableUtil.TryGetTable(Workbook workbook, String worksheetName, String tableName, ListObject& table)

at Smrf.NodeXL.ExcelTemplate.PerWorkbookSettings.TryGetPerWorkbookSettingsTable(ListObject& oPerWorkbookSettingsTable)

at Smrf.NodeXL.ExcelTemplate.PerWorkbookSettings.GetAllSettings()

at Smrf.NodeXL.ExcelTemplate.PerWorkbookSettings.TryGetValue(String settingName, Type valueType, Object& value)

at Smrf.NodeXL.ExcelTemplate.PerWorkbookSettings.get_WorkbookSettings()

at Smrf.NodeXL.ExcelTemplate.NodeXLApplicationSettingsBase.CopyWorkbookSettingsToStandardSettings()

at Smrf.NodeXL.ExcelTemplate.NodeXLApplicationSettingsBase.get_Item(String propertyName)

at Smrf.NodeXL.ExcelTemplate.GraphMetricUserSettings.get_GraphMetricsToCalculate()

at Smrf.NodeXL.ExcelTemplate.GraphMetricUserSettings.ShouldCalculateGraphMetrics(GraphMetrics graphMetrics)

at Smrf.NodeXL.ExcelTemplate.CalculateGraphMetricsContext.ShouldCalculateGraphMetrics(GraphMetrics graphMetrics)

at Smrf.NodeXL.ExcelTemplate.OverallMetricCalculator2.TryCalculateGraphMetrics(IGraph graph, CalculateGraphMetricsContext calculateGraphMetricsContext, GraphMetricColumn[]& graphMetricColumns)

at Smrf.NodeXL.ExcelTemplate.GraphMetricCalculationManager.CalculateGraphMetricsAsyncInternal(CalculateGraphMetricsAsyncArgs oCalculateGraphMetricsAsyncArgs, BackgroundWorker oBackgroundWorker, DoWorkEventArgs oDoWorkEventArgs)

at Smrf.NodeXL.ExcelTemplate.GraphMetricCalculationManager.BackgroundWorker_DoWork(Object sender, DoWorkEventArgs e)

at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)

at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

OK

Jun 15, 2013 at 6:39 PM
Did you have Office 2013 Preview or Office 2013 installed on this computer at one time? This problem occurred for another person, and that was the cause. Please see "problem when try to generate graph metrics" at http://nodexl.codeplex.com/discussions/392897.

-- Tony
Jun 15, 2013 at 7:26 PM
Hi Tony. I already had checked out that ticket. This is a straight office 2007 installation with service packs and hotfixes installed. Office 10/13 has not been near this machine. Thx. CK



Sent from my U.S. Cellular BlackBerry® smartphone

Jun 17, 2013 at 5:36 PM
This one is a real mystery. With the scenario you described, NodeXL should (and usually does) just work.

But here are a couple of things you can try:

1. Reinstall the Office 2007 PIAs. Those are the "connectors" that allow NodeXL to communicate with Excel. The PIAs get automatically installed by NodeXL's setup program, but perhaps something went wrong there.

To do this, close all Excel windows, then download and install the PIAs from http://www.microsoft.com/en-us/download/details.aspx?id=18346. Carefully read the "Install Instructions" on the web page, and note that you first have to run PrimaryInteropAssembly.exe to extract some files, and then double-click the extracted o2007PIA.msi file.

Now try NodeXL again. Does the error still occur?

2. Post a sample NodeXL workbook that has the problem. This will allow me to rule out a corrupt workbook.

You can't attach files on NodeXL's Discussions tab, but if you create a new issue on the Issues tab at http://nodexl.codeplex.com/workitem/list/basic, you can attach the workbook there. You don't have to explain anything in the new issue; I'll know what it is.

-- Tony
Jun 21, 2013 at 9:44 PM
Thanks Tony. I downloaded and installed the PIA per instructions and did not have any different result. I have uploaded the file that generates this issues here:

https://nodexl.codeplex.com/workitem/24432

Thanks, Chris
Jun 22, 2013 at 6:34 PM
Chris:

Unfortunately, your workbook opened and calculated graph metrics without a problem on my computer. I was hoping a workbook corruption issue would explain things.

I'm stumped at the moment. I'll try to think of other possible causes this weekend.

-- Tony
Jun 25, 2013 at 4:59 AM
Edited Jun 25, 2013 at 5:00 AM
I've attached a test program called TestExcel.exe at http://nodexl.codeplex.com/workitem/24432. Can you please do the following:

1 Download TestExcel.exe to your desktop.

2 Double-click TestExcel.exe on your desktop.

Here is what should happen:

3 The program should open an Excel window.

4 A message should pop up saying "The program worked properly."

Tell me if that actually occurs on your computer.

I've also attached the source code for the program (which is very simple), in case anyone wants to see what it's doing.

Thanks,
Tony
Jun 25, 2013 at 5:51 AM
Thanks for the followup. I ran the program and Excel did not launch, I got an error window with the following message. Thanks, Chris



---------------------------

---------------------------
A problem occurred. You can press Ctrl-C to copy the details to the Windows Clipboard.



Message:



Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).



Stack trace



at Microsoft.Office.Interop.Excel.ApplicationClass.set_Visible(Boolean RHS)

at TestExcel.Program.Main(String[] args)




---------------------------
OK
---------------------------






On 6/24/2013 10:59 PM, tcap479 wrote:

From: tcap479

I've attached a test program called TestExcel.exe at http://nodexl.codeplex.com/workitem/24432. Can you please do the following:
  1. Download TestExcel.exe to your desktop.
  2. Double-click TestExcel.exe on your desktop.
Here is what should happen:
  1. The program should open an Excel window.
  2. A message should pop up saying "The program worked properly."
Tell me if that actually occurs on your computer.

I've also attached the source code for the program (which is very simple), in case anyone wants to see what it's doing.

Thanks,
Tony

--

/////\/////\
Christopher G. Kolar
Director of Institutional Research,
Illinois Mathematics and Science Academy
[email removed] -- staff.imsa.edu/~ckolar -- 630.907.5069
NCSSSMST Board of Directors - www.ncsssmst.org
Committee for the Advancement of STEM Specialty Schools (CASSS) -- 202.656.5276

Jun 25, 2013 at 7:40 PM
Edited Jun 25, 2013 at 9:59 PM
Thanks for trying that, Chris.

Your copy of Excel is defective. The Excel program itself might work just fine, but when other programs like NodeXL (or the test program I wrote, which has nothing to do with NodeXL) attempt to communicate with Excel, they will fail.

I don't know how this happened. The most common causes I encountered in my research have to do with multiple versions of Office and/or Microsoft Visual Studio being installed on the same computer at various times, but there are probably other causes as well.

You can try to fix this by running the Office "detect and repair" utility, which you can read about at http://support.microsoft.com/kb/924611. If that doesn't work, I have no other advice except to try removing and reinstalling Office, which is pretty extreme.

Sorry I can't be more helpful.

-- Tony
Jun 26, 2013 at 3:28 PM
Thanks for all of the help Tony. My IT department says that I am in the queue for an upgrade, so I will put this onto the back burner and will try again once I have a fresh install. I appreciate the time that you spent trying to sort this out for me.

Chris


On 6/25/2013 1:40 PM, tcap479 wrote:

From: tcap479

Thanks for trying that, Chris.

Your copy of Excel is defective. The Excel program itself might work just fine, but when other programs like NodeXL attempt to communicate with Excel, they will fail.

I don't know how this happened. The most common causes I encountered in my research have to do with multiple versions of Office and/or Microsoft Visual Studio being installed on the same computer at various times, but there are probably other causes as well.

You can try to fix this by running the Office "detect and repair" utility, which you can read about at http://support.microsoft.com/kb/924611. If that doesn't work, I have no other advice except to try removing and reinstalling Office, which is pretty extreme.

Sorry I can't be more helpful.

-- Tony

--

/////\/////\
Christopher G. Kolar
Director of Institutional Research,
Illinois Mathematics and Science Academy
[email removed] -- staff.imsa.edu/~ckolar -- 630.907.5069
NCSSSMST Board of Directors - www.ncsssmst.org
Committee for the Advancement of STEM Specialty Schools (CASSS) -- 202.656.5276

Jun 26, 2013 at 6:47 PM
I note with interest your comment about having an IT department. We've had a handful of problems running NodeXL on computers that are managed by IT staff. Some we've solved and some we haven't, and I've often suspected that the unsolved mysteries are side effects of the steps that IT people take to protect the computers under their control. I'll file this one under "possibly due to IT-managed environment, or maybe it's just an old XP machine that's been around the block too many times."

In any case, I hope you get your upgrade soon.

-- Tony