IntelliSense
IntelliSense copied to clipboard
Excel-DNA IntelliSense v1.1.0 crashes Excel when I close Excel
If I remove Excel-DNA IntelliSense v1.1.0 my adding shutdowns correctly (no message "recoving...") If I include Excel-DNA IntelliSense v1.1.0, Excel crashes when I close it. Help...
@nsulikowski I'd like to investigate this, but I don't see that behaviour with a simple add-in. Could you please provide some detailed instructions on how I could recreate the crash you see?
Hi Govert. Thanks for your prompt response. Let's start with some environment info... please guide me as we go along on what else you'd like to know:
- Windows 7 Enterprice, SP1, 64bit, RAM 96GB
- Excel 2016, Microsoft Office 365 ProPlus , 64bit
- My addin: 64bit, 2795 functions decorated with [ExcelFunction], with various number of arguments (from 0 to 43 arguments)
If I do:
- add
<Reference Path="ExcelDna.IntelliSense.dll" Pack="true" />
in ExcelDNA64-AddIn.dna - call IntelliSenseServer.Install() inside AutoOpen()
- call IntelliSenseServer.Uninstall() inside AutoClose()
then Excel crashes when I close it. If I remove 1,2 and 3 it does not crash
BTW, v1.1.0 solved a problem I used to have, where by my Desktop Window Manager would crash with the following popup when I opened the DNA addin:
Desktop Window Manger: Desktop Window Manager stopped working and was closed A problem caused the application to stop working correctly. WIndows will notify you if a solution is available
So, thank you for fixing that.
OK - I have not tested recently under 64-bit Excel, and will try over the weekend. Are you able to:
- Test under 32-bit Excel to see if the problem is there too?
- Make a new tiny add-in that you can share online, to see if that exhibits the same problem?
The changes after version 1.0.8 were to fix problems like the Desktop Window Manager as you describe. But the new version might have introduced some other problems.... Unfortunately it's a really tricky context to work in.
I see similar problem on my machine (Windows 10 x64 Build 1803, Excel 2016 x64 1805 (Build 9330.2118 Click-to-Run), but it shows "assertion failed" instead of just crash.
- Download/checkout latest source for IntelliSense, build
- Double-click the ExcelDna.IntelliSense.Host-AddIn64.xll (it opens with Excel).
- Close the Excel (do not change/edit anything).
The following message appears:
Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue
at ExcelDna.IntelliSense.WindowWatcher.UpdateFocus(IntPtr windowHandle, String windowClassName) in [path]\ExcelDna.IntelliSense\UIMonitor\WindowWatcher.cs:line 158 at ExcelDna.IntelliSense.WindowWatcher._windowStateChangeHook_WinEventReceived(Object sender, WinEventArgs e) in [path]\ExcelDna.IntelliSense\UIMonitor\WindowWatcher.cs:line 200 at ExcelDna.IntelliSense.WinEventHook.OnWinEventReceived(Object winEventArgsObj) in [path]\ExcelDna.IntelliSense\UIMonitor\WinEvents.cs:line 232 at ExcelDna.IntelliSense.SingleThreadSynchronizationContext.RunOnCurrentThread() in [path]\ExcelDna.IntelliSense\SingleThreadSynchronizationContext.cs:line 54 at ExcelDna.IntelliSense.UIMonitor.RunUIAutomation() in [path]\ExcelDna.IntelliSense\UIMonitor\UIMonitor.cs:line 60 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
@hell-racer I think that's the assertion that matches the Warning described here: https://github.com/Excel-DNA/IntelliSense/issues/66
But I did not think in the release build that it would crash Excel.
@govert any update on this? We are witnessing these crashes within our user base
@hdwatts Do you have a ribbon interface as part of your add-in?
If so, you might want to experiment with calling IntellisenseServer.Uninstall()
in the OnBeginShutdown
override of the ribbon class. I'm hoping that's a good time to unhook the Intellisense, before the causing the crash at shutdown.
I'm not in a position to test this myself, so any feedback would be welcome.
Thanks @govert , so that solution fixes the crashing, however now the Intellisense popups seem to be restricted to the main monitor. If a user with a laptop has excel on an external monitor then the popup remains stuck on the laptop screen. We've also seen it appear on the same screen but not positioned properly below the cell.
I'm continuing to look into it but wanted to raise with you to see if you've encountered this before.
EDIT: Looks like the monitor behavior is present before this fix, so I will say moving the Uninstall
call to the OnBeginShutdown
is a great fix! Thanks @govert. Let me know if there is anything I can do to help debug this monitor situation though.
While continuing to test @govert, it looks like it is crashing if another Add-In uses IntelliSense
I get the error:
Attempt by method 'WrapperType.Wrapped_f16_IntelliSenseServerControl(System.Object)' to access method 'ExcelDna.IntelliSense.IntelliSenseServer.IntelliSenseServerControl(System.Object)' failed.
Which I assume is due to it being already Uninstalled from the Ribbon and then the other addin is attempting to Uninstall again.
I've reverted down to 1.0.8 and the crashing is no longer present.
@hdwatts I think this should be resolved with version 1.4.1. Could you perhaps have a look?
Alas, unfortunately @govert it does not appear to be resolved.
I did the following:
- Updated to 1.4.1
- Updated my IntelliSense calls from Register in AutoOpen to Install
- Added an IntelliSense call to Uninstall in AutoClose.
The Excel crash when closing issue occurred. My event viewer details are below. I reverted back to 1.0.8 and reverted my IntelliSense calls, opened/closed the same file, and there was no crash.
I unfortunately cannot share this file as it was provided by a client, however if it will help you debug it is a large (4.14MB) .xlsm
file, and I can consistently replicate the issue by:
- Having Excel closed
- Opening the .xlsm file from the file explorer
- Closing the workbook.
Let me know if I can provide any additional details.
Event Viewer Message:
Faulting application name: EXCEL.EXE, version: 16.0.12527.21330, time stamp: 0x5fa5edd0
Faulting module name: KERNELBASE.dll, version: 10.0.18362.959, time stamp: 0x51671cfe
Exception code: 0xc0020001
Fault offset: 0x001143d2
Faulting process id: 0x4b7c
Faulting application start time: 0x01d6c73daccdc822
Faulting application path: C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 72218ff8-4144-4d88-aae7-a04f937c66b9
Faulting package full name:
Faulting package-relative application ID:
@hdwatts Thanks for following up.
Is the error you see is still the same one -
Attempt by method 'WrapperType.Wrapped_f16_IntelliSenseServerControl(System.Object)' to access method
'ExcelDna.IntelliSense.IntelliSenseServer.IntelliSenseServerControl(System.Object)' failed.
That was, at least in part, related to a bug in version 1.3.0 & 1.40 which should be fixed now.
Do you mean the error happens when the workbook is closed, not when Excel is closed?
I wonder if there might be multiple versions of the IntelliSense involved. Could you perhaps run this VBA code in a problem environment and check the results in the Immediate Window:
Sub DumpIntelliSenseVars()
Debug.Print Environ("EXCELDNA_INTELLISENSE_DISABLEDVERSIONS")
Debug.Print Environ("EXCELDNA_INTELLISENSE_SERVERS")
Debug.Print Environ("EXCELDNA_INTELLISENSE_ACTIVE_SERVER")
End Sub
I'm expecting the first one to be empty, and the same (only one) entry in the other two.
I unfortunately do not recall how I was able to replicate the WrapperType error🤦♂️. I did attempt to wrap my AutoClose in a try/catch which did not get hit. I imagine that was my flow back in February- so I think it should be ok.
Here are my results from the VBA code in the problematic sheet - it does appear the second line has two entries!
[empty]
C:\Users\HDWatts\AppData\Roaming\Microsoft\AddIns\xConnectCore-packed.xll,4890b01577684a3fb3c3bf5d7ad19189,1.4.1;C:\Users\HDWatts\AppData\Roaming\Microsoft\AddIns\xConnectCore-packed.xll,a22169a2a8df4ca8949fa19dc7728c14,1.4.1
C:\Users\HDWatts\AppData\Roaming\Microsoft\AddIns\xConnectCore-packed.xll,4890b01577684a3fb3c3bf5d7ad19189,1.4.1
Is your add-in perhaps loaded twice - once from being on the Excel add-ins list and again from the debugger, double-click or File->Open ? Or maybe the .xlsm is doing Application.RegisterXLL.
Can you try to figure out whether the double-loading is related to the crash you see That might be a clue to let me reproduce the error here.
Also, does the crash happen when the workbook is closed but Excel is still open (e.g. if another workbook is still open) or do you have the crash when you shut Excel down while the workbook is open?
Thanks for getting back to me @govert, and I'm glad we have a lead here.
I am only running Excel via windows explorer, not through the VS debugger. I have two files, "testdebug.xlsm" which has the print macro. The other file "client_file.xlsm" has a password protected VBA project which I unfortunately cannot access...sincerest apologies about this if you suspect that the issue could lie within that project. I'll note that in my testing, when opening client_file.xlsm via double click and trying to run one of their macros, I got a message about all macros being disabled.
Here are two detailed workflows:
- I have no instances of Excel open.
- I open testdebug.xlsm via double click, open VBA with Alt + F11
- I run the macro. Only one output occurs
- I open client_file.xlsm via double click
- I rerun the macro. Only one output occurs
- I close testdebug.xlsm via alt + F4 and close client_file.xlsm via alt + F4
- Crash occurs
- I open Excel
- I open client_file.xlsm via File -> Open
- I open testdebug.xlsm via File -> Open
- I run the macro and there are two outputs
- I close testdebug.xlsm via alt + f4 and close client_file.xlsm via alt + F4
- No crash occurs
It appears that maybe the double-loading is unrelated, as I was able to view two outputs and not replicate the crash while using File -> Open.
To confirm, I did the following:
- I have no instances of Excel open
- I open client_file.xlsm via double click
- I open testdebug.xlsm via double click
- I run the macro and there are two outputs
- I close testdebug.xlsm via alt + f4 and close client_file.xlsm via alt + F4
- Crash occurs
Finally, with regards to your last question, I ran the same steps as above but closed the files via File -> Close:
- I have no instances of Excel open
- I open client_file.xlsm via double click
- I open testdebug.xlsm via double click
- I close testdebug.xlsm via file -> close
- I close client_file.xlsm via file -> close
- No crash occurs
- I close Excel
- Crash occurs
Thank you for the additional details. I see that the crash only occurs when exiting Excel.
I'm interested in how this add-in is loaded:
C:\Users\HDWatts\AppData\Roaming\Microsoft\AddIns\xConnectCore-packed.xll
It seems like this add-in is loaded twice (hence two two entries in the environment variable you saw from VBA). I can only guess that it is loaded once because it is installed as an add-in, and then a second time from one of those .xlsm files.
I wonder if you go into the Excel add-ins dialog (Alt+t,i) and then uncheck the add-in if it appears there, then close everything and retest.
If it does not appear there, maybe both of the .xlsm add-ins are trying to load this add-in explicitly?
Thanks Govert, I've disabled the add-in and the test flows are outlined below:
- I have no instances of Excel open
- I open client_file.xlsm via double click
- I open testdebug.xlsm via double click
- I run the macro, immediate window shows 3 empty lines
- I close testdebug.xlsm via alt + f4
- I close client_file.xlsm via alt + f4
- No crash occurs
For what its worth, my testdebug.xlsm
is an entirely empty file with just the debug macro, and with no explicit loading of the addin.
I've also have this curious replication workflow:
- No instances of Excel open
- No addins enabled in Excel
- Open client_file.xlsm via double click
- Enable our add in
- Close Excel via alt + F4
- Crash occurs
Finally, I deleted all sheets in the client file, saved, closed (crash occurred), and reran the problematic workflow. The issue persisted. I think it is safe to assume something in the client macros is causing this.
As a last note for this message, in none of my previous tests have I interacted with this security window:
I enabled the content, but the crash still occurred upon close.
My next step in testing is to try with a totally bare bones add-in, I will let you know my the results of that test in my next message.
Are you able to cause the crash without ever loading client_file.xlsm?
Does client_file.xlsm have a hidden sheet called "IntelliSense" ? That would interact with the IntelliSense add-in, though not explain the crash.
I guess it may also be loading some native libraries, which the IntelliSense monitors and something related goes wrong.
I've never been able to cause the crash without client_file.xlsm, and I wanted to just chalk this up to a "Client Problem" until I saw this issue was posted and figured it may be a bit more widespread.
I just finished testing with a barebones add-in, which I can publish to a repo if you'd like. It only consists of the hello world function, AutoOpen/AutoClose to install IntelliSense, and the reference line to pack IntelliSense into the .xll file. The crash occurs.
There are no hidden sheets called "IntelliSense", as of now client_file is totally blank with the exception of the password protected VBA Project which I cannot access.
There are not a lot of clues as to what your file might be doing. I guess some .dlls are loaded that somehow interfere with the IntelliSense.
Are you able to run Excel under a debugger? I think the debug output will show at least some of the other .dlls loaded, and maybe something more about the error.
The actual error you see (0xc0020001) is quite strange, it means "The string binding is invalid." but seems to relate to an interaction between .NET and the C runtime. The IntelliSense add-in does monitor the dll loading and unloading, so I presume something is going wrong there. But I'm not sure what exactly inside your workbook code triggers the problem - maybe it is a particular .dll it loads.
Good thought with the .dll debugging, I've been unable so far to find more information about the error however did get a list of DLLs loaded by an empty sheet vs with the client sheet. The results are below:
https://docs.google.com/spreadsheets/d/1urL_PZMGCeHZIQH1l3j2I8y9_F_t9qyUc752lrnLgzQ/edit?usp=sharing
For anyone also desperately looking for a solution for the "excel-crashing-when-closing" problem (and successfully deriving to be an Excel-DNA-Intellisense-Server issue of course!), I managed to get rid of it, by following Goverts advice to uninstall the Intellisense server on shutdown (here I'm using my Ribbon MenuHandler, but you can also roll your own event handler by subclassing ExcelComAddin (see below the MenuHandler example):
<ComVisible(True)>
Public Class MenuHandler
Inherits CustomUI.ExcelRibbon
''' <summary>callback after Excel loaded the Ribbon, used to initialize data for the Ribbon</summary>
Public Sub ribbonLoaded(theRibbon As CustomUI.IRibbonUI)
MenuHandlerGlobals.theRibbon = theRibbon
initAdhocSQLconfig()
End Sub
Public Overrides Sub OnBeginShutdown(ByRef custom As Array)
ExcelDna.IntelliSense.IntelliSenseServer.Uninstall()
End Sub
<ComVisible(True)>
Public Class MyComAddin
Inherits ExcelComAddIn
Public Overrides Sub OnBeginShutdown(ByRef custom As Array)
ExcelDna.IntelliSense.IntelliSenseServer.Uninstall()
End Sub
End Class
<ComVisible(True)>
Public Class AddInEvents
Implements IExcelAddIn
Private com_addin As ExcelComAddIn
Public Sub AutoOpen() Implements IExcelAddIn.AutoOpen
com_addin = New MyComAddin()
com_addin.GetType().InvokeMember("DnaLibrary", System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.SetProperty, Nothing, com_addin, New Object() {DnaLibrary.CurrentLibrary})
ExcelComAddInHelper.LoadComAddIn(com_addin)
End Sub
End Class