Posted by ToM on 16. Juli 2009 under VSTO Excel |
We observed a very strange behaviour while updating cells when the user is currently editing a cell.
After doing some research on the net it seems that the only solution to determine if the cell is in edit mode is a very strange hack
Obviously, the Application object has a method called GoTo(Range) to navigate to some areas. Somehow throws this method a special exception if it’s in edit mode. So the strange solution so far is to call Application.GoTo(”###”) and see what kind of exception it throws
protected bool isInEditMode()
{
try
{
this.Application.Goto("###", false);
}
catch (Exception ex)
{
if (ex.Message.StartsWith("Reference is not valid"))
return false;
else
return true;
}
return false;
}
Posted by ToM on 1. April 2009 under Debugging Tips |
A very helpful trick is to set an user environment variable called VSTO_SUPPRESSDISPLAYALERTS to 0, this gives you more detailed information what’s going wrong during runtime.
Posted by ToM on under Debugging Tips |
If some of the components don’t load correctly and seem to do really nothing, you’ve a great chance that one or more of the required dependencies can’t be loaded.
Windows offers you a possibility to inspect what exactly happens when the assemblies are loaded (or not *g*)…The fusion log.
To enable the fusion log, create a directory to retrieve the log’s output, let’s say c:\fusionlog.
Now, several registry keys need to be set in order to enable the logging:
- Set the path to your logfile directory in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion\LogPath (in our example c:\fusionlog)
- Set HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion\LogFailures to 1
- Optionally set HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion\ForceLog to 1
- Optionally set HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion\LogResourceBinds to 1
There’s a tool called “Assembly Binding Log Viewer” available in the .NET Framework SDK, for more information look here.