rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.92k stars 302 forks source link

COM Exception while runing unit tests #3986

Closed marcinczerny closed 5 years ago

marcinczerny commented 6 years ago

I am using proficy iFix that includes built-in VBE. The problem is that as soon as the "Run test" Button is hit, the attached exception is shown and tests stop working. On the other hand tests written in Excel are fine and they pass (or fail) every time. We were testing on computers with Office 2007 and 2013. The interesting thing is that on Office 2003 and the same iFix version everything works just fine - including testing in iFix VBE. Error.txt

Vogel612 commented 6 years ago

Stacktrace from Log:

System.Runtime.InteropServices.COMException (0x800A9D9F): Exception from HRESULT: 0x800A9D9F
   at Rubberduck.VBEditor.ComManagement.TypeLibsSupport.IVBETypeInfo.GetStdModAccessor()
   at Rubberduck.VBEditor.ComManagement.TypeLibs.TypeInfoWrapper.GetStdModAccessor() in C:\projects\rubberduck\Rubberduck.VBEEditor\ComManagement\TypeLibs\TypeInfos.cs:line 642
   at Rubberduck.VBEditor.ComManagement.TypeLibs.TypeInfoWrapper.StdModExecute(String name, Object[] args) in C:\projects\rubberduck\Rubberduck.VBEEditor\ComManagement\TypeLibs\TypeInfos.cs:line 667
   at Rubberduck.VBEditor.ComManagement.TypeLibsAPI.VBETypeLibsAPI.ExecuteCode(TypeLibWrapper projectTypeLib, String standardModuleName, String procName, Object[] args) in C:\projects\rubberduck\Rubberduck.VBEEditor\ComManagement\TypeLibs\TypeLibsAPI.cs:line 211
   at Rubberduck.UnitTesting.TestEngine.Run(IEnumerable`1 members) in C:\projects\rubberduck\Rubberduck.Core\UnitTesting\TestEngine.cs:line 160
   at Rubberduck.UnitTesting.TestEngine.RunInternal(IEnumerable`1 tests) in C:\projects\rubberduck\Rubberduck.Core\UnitTesting\TestEngine.cs:line 112
   at Rubberduck.UnitTesting.TestEngine.<>c__DisplayClass19_0.<Run>b__0() in C:\projects\rubberduck\Rubberduck.Core\UnitTesting\TestEngine.cs:line 87
   at Rubberduck.Parsing.UIContext.UiDispatcher.<>c__DisplayClass2_0.<InvokeAsync>b__0(Object x) in C:\projects\rubberduck\Rubberduck.Parsing\UIContext\UiDispatcher.cs:line 27

@marcinczerny could you please check the logs under %APP_DATA%\Rubberduck\logs for more information?

From your description of Office 2003 and Office 2007 this seems like it might be related to the incompatibilities in Office that show up when installing Office in something else than release order... Was Office installed before iFix on the Computer where this shows up?

marcinczerny commented 6 years ago

@Vogel612

Thanks for your reply. Yes, Office was installed before iFix because that is mandatory. I can't see anything interesting in logs either, there are no errors, just ordinary info that the test was completed, although it wasn't because of the thrown exception. INFO-2.2.6672.28001;Rubberduck.UI.UnitTesting.TestExplorerViewModel;Test run completed in 0.;

RubberduckLog.txt

bclothier commented 6 years ago

@marcinczerny

The reason why the log didn't have any data was due to the fact that the try/catch does not wrap all the operations -- we had one for the individual unit tests but not for the initialization or for the cleanup.

If you want, you can fetch the pre-release here where we add the additional try blocks; that would hopefully cause the error to be logged so we can diagnose why it's not working on the FixIt VBE.

WaynePhillipsEA commented 6 years ago

Error code 0x800A9D9F suggests a security related error. It could be that the host is not setting the VBA security level, leaving some features unavailable.

IIRC, Office 2007 introduced Trusted Locations, with VBA being disabled from untrusted locations, and it could be that the VBE is expecting the host to inform it that the document is considered from a safe location in later versions of the VBA SDK.

Have a route around in the hosts settings/options to see if there is anything VBA/security related.

marcinczerny commented 6 years ago

@bclothier I have attached a file with logs.

@WaynePhillipsEA There are no options related to VBA/Security as far as I am concerned. I have tried to add the iFix project to Trusted Locations in Office, but that's not working either. own is supported RubberduckLog.txt

bclothier commented 6 years ago

Just to verify - Is your testing doing any automation with any of Office components?

marcinczerny commented 6 years ago

No, I was trying to do some dummy tests like Assert.IsTrue True, etc, just to check the rubberduck.

bclothier commented 5 years ago

Following up on this old issue - since then there has been several changes to the COM reference collector. Want to confirm if this might had fixed the issue or not.

bclothier commented 5 years ago

We are closing this in the assumption that this has been fixed. If anyone finds out to contrary, please reopen.