ExcelDna.IntelliSense: Object reference not set to an instance of an object

174 views
Skip to first unread message

Elvis Hsu

unread,
Nov 24, 2017, 8:25:09 AM11/24/17
to Excel-DNA

Hi Excel-DNA Team,

Recently I have discovered an interesting exception when using ExcelDna.IntelliSense.dll library.

Scenario:
  1. Compile and pack the XLL with IntelliSense registered and assembly version 1.0.0. ie. IntelliSense.Test.xll
  2. Compile and pack the XLL with IntelliSense registered and assembly version 1.0.1. ie. IntelliSense.Test.xll
  3. (Note: The XLL file name for both versions are the same)
  4. Place the IntelliSense.Test.xll to C:\1.0.0\IntelliSense.Test.xll and C:\1.0.1\IntelliSense.Test.xll
  5. Open Excel and load C:\1.0.0\IntelliSense.Test.xll
  6. Unload/unregister IntelliSense.Test.xll
  7. Use the same Excel instance to load C:\1.0.1\IntelliSense.Test.xll
  8. Kaboom - NullReference Exception is thrown



I guess the exception is thrown from this line (Maybe we should do a null check on it to avoid null reference exception?):



What I don't understand is "Why the following line produces a null event argument?"


Any help/hint would be appreciated!!


Cheers,
Elvis

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at ExcelDna.Integration.ExcelSynchronizationContext.Post(SendOrPostCallback d, Object state)
   at ExcelDna.IntelliSense.ExcelDnaIntelliSenseProvider.ProcessLoadNotification(Object state)


************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.




Govert van Drimmelen

unread,
Dec 3, 2017, 2:34:08 PM12/3/17
to Excel-DNA
Hi Elvis,

Excel-DNA add-ins that use some of the COM features, like RTD or Ribbon integration, can't be reloaded safely.
I suspect you're seeing the same issue with the IntelliSense add-in.

If you rename the add-ins to have version-specific names, they should load as separate add-ins and it should work.
But as it is, because the have the same name, there is some confusion between Excel and Excel-DNA.

-Govert
Reply all
Reply to author
Forward
0 new messages