Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RD 2.0.8 Error HRESULT E_FAIL has been returned from a call to a COM component #2217

Closed
eteichm opened this issue Sep 4, 2016 · 3 comments
Closed
Labels
bug Identifies work items for known bugs critical Marks a bug as a must-fix, showstopper issue feature-inspections
Milestone

Comments

@eteichm
Copy link

eteichm commented Sep 4, 2016

Following #2210, I manually added a couple of lines "'@ignore ProcedureNotUsed" and got the following error: "Error HRESULT E_FAIL has been returned from a call to a COM component". I clicked Continue and restarted Excel. It occurred only once.

More details:
Unhandled exception has occurred in a component in your application. If you click Continue, the application will ignore this error and attempt to continue.
Error HRESULT E_FAIL has been returned from a call to a COM component.

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

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at Microsoft.Vbe.Interop._VBComponent.get_Type()
at Rubberduck.Common.DeclarationExtensions.<>c.b__23_0(Declaration item) in C:\Users\hosch\Documents\Visual Studio 2015\Projects\Rubberduck\RetailCoder.VBE\Common\DeclarationExtensions.cs:line 354
at System.Linq.Enumerable.WhereListIterator1.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at Rubberduck.Common.DeclarationExtensions.FindFormEventHandlers(RubberduckParserState state) in C:\Users\hosch\Documents\Visual Studio 2015\Projects\Rubberduck\RetailCoder.VBE\Common\DeclarationExtensions.cs:line 354
at Rubberduck.Inspections.ParameterCanBeByValInspection.GetInspectionResults() in C:\Users\hosch\Documents\Visual Studio 2015\Projects\Rubberduck\RetailCoder.VBE\Inspections\ParameterCanBeByValInspection.cs:line 32
at (Object , Object[] )
at Ninject.Extensions.Interception.Injection.Dynamic.DynamicMethodInjector.Invoke(Object target, Object[] arguments)
at Ninject.Extensions.Interception.Invocation.Invocation.CallTargetMethod()
at Ninject.Extensions.Interception.Invocation.InvocationBase.Proceed()
at Rubberduck.Root.InterceptorBase.Intercept(IInvocation invocation) in C:\Users\hosch\Documents\Visual Studio 2015\Projects\Rubberduck\RetailCoder.VBE\Root\InterceptorBase.cs:line 13

...

************** 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:

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.

@retailcoder retailcoder added bug Identifies work items for known bugs critical Marks a bug as a must-fix, showstopper issue labels Sep 6, 2016
@retailcoder retailcoder added this to the Version 2.0 milestone Sep 6, 2016
@retailcoder
Copy link
Member

This line is in the stack trace:

var formEventHandlerScopes = State.FindFormEventHandlers().Select(handler => handler.Scope);

The offending code is an extension method:

        var items = state.AllDeclarations.ToList();
        var forms = items.Where(item => item.DeclarationType == DeclarationType.ClassModule
            && item.QualifiedName.QualifiedModuleName.Component != null
            && item.QualifiedName.QualifiedModuleName.Component.Type == vbext_ComponentType.vbext_ct_MSForm)
            .ToList();

A COMException is thrown accessing the Component.Type; this points to AllDeclarations containing invalid pointers to a VBComponent object.

I think we might need to rethink how we're accessing and storing these COM objects - perhaps just store the name (along with the ProjectId), and then retrieve the actual VBComponent object directly from the VBIDE API, fire-and-forget - fetch the COM object, get whatever property value(s) we're interested in, and then discard the object.

Not storing COM objects anywhere (anywhere it's possible not to, at least) would tremendously help stabilize 2.0 I think.

@Vogel612
Copy link
Member

Vogel612 commented Jan 8, 2017

@retailcoder fixed with the SafeComWrappers?

@retailcoder
Copy link
Member

@Vogel612 likely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies work items for known bugs critical Marks a bug as a must-fix, showstopper issue feature-inspections
Projects
None yet
Development

No branches or pull requests

3 participants