MathewSachin / Captura

Capture Screen, Audio, Cursor, Mouse Clicks and Keystrokes
https://mathewsachin.github.io/Captura/
MIT License
9.81k stars 1.84k forks source link

The invocation of the constructor on type 'Captura.MainWindow' that matches the specified binding constraints threw an exception. #501

Closed akuropka closed 4 years ago

akuropka commented 4 years ago

Error happens on v0.0.3422 and later. Captura.exe seems to be still running in the background but there's no systray icon.

The invocation of the constructor on type 'Captura.MainWindow' that matches the specified binding constraints threw an exception.

System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'Captura.MainWindow' that matches the specified binding constraints threw an exception. ---> System.Runtime.InteropServices.COMException: Element nicht gefunden. (Exception from HRESULT: 0x80070490) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at NAudio.CoreAudioApi.MMDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow dataFlow, Role role) at Captura.Audio.NAudioItem.get_DefaultMicrophone() at Captura.Audio.NAudioSource.get_DefaultMicrophone() at Captura.Models.AudioSourceViewModel.RefreshMics() at Captura.Models.AudioSourceViewModel..ctor(IAudioSource AudioSource) at DynamicInjectore1e462a108ac4972a94cc0b705d38fb3(Object[] ) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.ResolveInternal(Object scope) at Ninject.Activation.Context.Resolve() at Ninject.KernelBase.Resolve(IRequest request, Boolean handleMissingBindings) at Ninject.KernelBase.Resolve(IRequest request) at Ninject.Planning.Targets.Target1.ResolveWithin(IContext parent) at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) at Ninject.Activation.Providers.StandardProvider.<>cDisplayClass15_0.b0(ITarget target) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.ResolveInternal(Object scope) at Ninject.Activation.Context.Resolve() at Ninject.KernelBase.Resolve(IRequest request, Boolean handleMissingBindings) at Ninject.KernelBase.Resolve(IRequest request) at Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) at Ninject.Activation.Providers.StandardProvider.<>cDisplayClass15_0.b0(ITarget target) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.ResolveInternal(Object scope) at Ninject.Activation.Context.Resolve() at Ninject.KernelBase.Resolve(IRequest request, Boolean handleMissingBindings) at Ninject.KernelBase.Resolve(IRequest request) at Ninject.Planning.Targets.Target1.ResolveWithin(IContext parent) at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) at Ninject.Activation.Providers.StandardProvider.<>c__DisplayClass15_0.<Create>b__0(ITarget target) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.ResolveInternal(Object scope) at Ninject.Activation.Context.Resolve() at Ninject.KernelBase.Resolve(IRequest request, Boolean handleMissingBindings) at Ninject.KernelBase.Resolve(IRequest request, Boolean handleMissingBindings) at Ninject.KernelBase.Resolve(IRequest request) at Ninject.ResolutionExtensions.GetResolutionIterator(IResolutionRoot root, Type service, Func2 constraint, IEnumerable1 parameters, Boolean isOptional, Boolean isUnique) at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters) at Captura.MainWindow..ctor() --- End of inner exception stack trace --- at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri) at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc) at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties) at System.Windows.Application.DoStartup() at System.Windows.Application.<.ctor>b__1_0(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'Captura.MainWindow' that matches the specified binding constraints threw an exception. ---> System.Runtime.InteropServices.COMException: Element nicht gefunden. (Exception from HRESULT: 0x80070490) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at NAudio.CoreAudioApi.MMDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow dataFlow, Role role) at Captura.Audio.NAudioItem.get_DefaultMicrophone() at Captura.Audio.NAudioSource.get_DefaultMicrophone() at Captura.Models.AudioSourceViewModel.RefreshMics() at Captura.Models.AudioSourceViewModel..ctor(IAudioSource AudioSource) at DynamicInjectore1e462a108ac4972a94cc0b705d38fb3(Object[] ) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.ResolveInternal(Object scope) at Ninject.Activation.Context.Resolve() at Ninject.KernelBase.Resolve(IRequest request, Boolean handleMissingBindings) at Ninject.KernelBase.Resolve(IRequest request) at Ninject.Planning.Targets.Target1.ResolveWithin(IContext parent) at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) at Ninject.Activation.Providers.StandardProvider.<>cDisplayClass15_0.b0(ITarget target) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.ResolveInternal(Object scope) at Ninject.Activation.Context.Resolve() at Ninject.KernelBase.Resolve(IRequest request, Boolean handleMissingBindings) at Ninject.KernelBase.Resolve(IRequest request) at Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) at Ninject.Activation.Providers.StandardProvider.<>cDisplayClass15_0.b0(ITarget target) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.ResolveInternal(Object scope) at Ninject.Activation.Context.Resolve() at Ninject.KernelBase.Resolve(IRequest request, Boolean handleMissingBindings) at Ninject.KernelBase.Resolve(IRequest request) at Ninject.Planning.Targets.Target1.ResolveWithin(IContext parent) at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) at Ninject.Activation.Providers.StandardProvider.<>c__DisplayClass15_0.<Create>b__0(ITarget target) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.ResolveInternal(Object scope) at Ninject.Activation.Context.Resolve() at Ninject.KernelBase.Resolve(IRequest request, Boolean handleMissingBindings) at Ninject.KernelBase.Resolve(IRequest request, Boolean handleMissingBindings) at Ninject.KernelBase.Resolve(IRequest request) at Ninject.ResolutionExtensions.GetResolutionIterator(IResolutionRoot root, Type service, Func2 constraint, IEnumerable1 parameters, Boolean isOptional, Boolean isUnique) at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters) at Captura.MainWindow..ctor() --- End of inner exception stack trace --- at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri) at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc) at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties) at System.Windows.Application.DoStartup() at System.Windows.Application.<.ctor>b__1_0(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

MathewSachin commented 4 years ago

I checked Release Portable builds on both v0.0.3428 (latest on audio-revamp branch) and v0.0.3430 (latest on master branch) and they seem to work fine for me.

Can you check again for these latest versions.

akuropka commented 4 years ago

Apologies for not checking the error in detail and what it may cause it. It seems it happens within a RDP session with remote audio device. If I start the app (installed or portable) within a local session it works as desired. Switching later to RDP causes the error as well.

MathewSachin commented 4 years ago

I think the problem might be that there is no default microphone or speaker. I'll add code for checking this in a few minutes.

MathewSachin commented 4 years ago

Please test v0.0.3450

https://ci.appveyor.com/api/buildjobs/kt012du6gtwtytco/artifacts/temp%2FCaptura-Portable.zip

akuropka commented 4 years ago

It works. (-: Thank you! There's a default speaker ("Remote Audio") but no microphone, right.

MathewSachin commented 4 years ago

Great! Thank you for reporting. I can see this error happening for someone whose system doesn't have an inbuilt microphone.

akuropka commented 4 years ago

Btw what I noticed it seems Captura now using permanently the mic even if I'm not using the app 20200322-135706 ...

MathewSachin commented 4 years ago

Yeah, that allows it to show peak levels in Settings/Audio screen.

akuropka commented 4 years ago

Windows 10 showing the usage of the mic is a security feature to prevent that someone listens unintentionally. This concept renders that idea pretty much useless. While it makes sens showing peak levels the usage of mic should be restricted when really needed e.g. during recording (if enabled) and being in the Settings/Audio screen. Just my two cents.

MathewSachin commented 4 years ago

Hmm... Sounds logical. I would try to push a commit in a few minutes.

MathewSachin commented 4 years ago

Does this build work as expected? https://ci.appveyor.com/api/buildjobs/ku952yens3ws71jg/artifacts/temp%2FCaptura-Portable.zip

My Windows 10 is pretty old. Might be the reason I don't have that feature.

akuropka commented 4 years ago

Works perfectly, thank you once again!