Rubberduck: Create Unit Test Module Does not work

Created on 26 Nov 2018  路  5Comments  路  Source: rubberduck-vba/Rubberduck

I tried changing the macro settings and then restarting the program. Am I doing this right? Thanks for the help!
capture

RubberduckLog.txt

bug feature-unit-testing has-workaround

All 5 comments

Macro security shouldn't need to be lowered (as long as macros are enabled and VBA code is allowed to run) - looks like we're going to have to ship a hotfix release this week...

The stacktrace in the log implies we're incorrectly handling a COM object in that part of the codebase. Thanks for the report :)

2018-11-25 21:37:01.8147;WARN-2.3.0.4221;Rubberduck.UI.UnitTesting.Commands.AddTestModuleCommand;Unable to add test module. An exception was thrown.;
2018-11-25 21:37:01.8277;WARN-2.3.0.4221;Rubberduck.UI.UnitTesting.Commands.AddTestModuleCommand;System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
   at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
   at Microsoft.Vbe.Interop._VBProject.get_Protection()
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBProject.get_Protection() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBProject.cs:line 49
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBProject.get_VBComponents() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBProject.cs:line 47
   at Rubberduck.UI.UnitTesting.Commands.AddTestModuleCommand.ExecuteInternal(IVBProject project, Declaration projectDeclaration) in C:\projects\rubberduck\Rubberduck.Core\UI\UnitTesting\Commands\AddTestModuleCommand.cs:line 195;System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
   at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
   at Microsoft.Vbe.Interop._VBProject.get_Protection()
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBProject.get_Protection() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBProject.cs:line 49
   at Rubberduck.VBEditor.SafeComWrappers.VBA.VBProject.get_VBComponents() in C:\projects\rubberduck\Rubberduck.VBEditor.VBA\SafeComWrappers\VB\VBProject.cs:line 47
   at Rubberduck.UI.UnitTesting.Commands.AddTestModuleCommand.ExecuteInternal(IVBProject project, Declaration projectDeclaration) in C:\projects\rubberduck\Rubberduck.Core\UI\UnitTesting\Commands\AddTestModuleCommand.cs:line 195

As a workaround you could add the module without involving Rubberduck. The module will still be discovered after parsing then.

unable to create test module

Adding test module manually does work though, and tests run fine.

Thanks, you folks are great. I hope to get on your level one day.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

connerk picture connerk  路  61Comments

UnhandledCoder picture UnhandledCoder  路  32Comments

ishita799 picture ishita799  路  28Comments

AndrewM- picture AndrewM-  路  37Comments

daFreeMan picture daFreeMan  路  25Comments