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

Exception has been thrown by the target of an invocation #306

Closed
WardenHub opened this issue Oct 4, 2022 · 5 comments · Fixed by #505
Closed

Exception has been thrown by the target of an invocation #306

WardenHub opened this issue Oct 4, 2022 · 5 comments · Fixed by #505

Comments

@WardenHub
Copy link

Brief description of your issue

When I try to make a manifest I get the error Exception has been thrown by the target of an invocation, see full errorstack below (Actual behavior)

This happens before I can input values.

Steps to reproduce

wingetcreate.exe new "https://download.advanced-ip-scanner.com/download/files/Advanced_Port_Scanner_2.5.3869.exe"

Expected behavior

Entering the prompted values

Actual behavior


wingetcreate.exe new "https://download.advanced-ip-scanner.com/download/files/Advanced_Port_Scanner_2.5.3869.exe"
Downloading and parsing: https://download.advanced-ip-scanner.com/download/files/Advanced_Port_Scanner_2.5.3869.exe...

This tool will walk you through a series of questions to help you create your package manifest.

For information about the restrictions for each field, visit https://github.com/microsoft/winget-cli/blob/master/doc/ManifestSpecv1.0.md

Press ENTER to submit the value for each question including accepting the (default) value.

Please enter values for the following fields:
The package unique identifier |e.g. Microsoft.VisualStudio|
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.IO.IOException: The handle is invalid.
   at System.ConsolePal.set_CursorVisible(Boolean value)
   at System.Console.set_CursorVisible(Boolean value)
   at Sharprompt.Drivers.DefaultConsoleDriver.Reset()
   at Sharprompt.Drivers.DefaultConsoleDriver.Dispose()
   at Sharprompt.Forms.FormRenderer.Dispose()
   at Sharprompt.Forms.FormBase`1.Dispose()
   at Sharprompt.Prompt.Input[T](InputOptions options)
   at Microsoft.WingetCreateCLI.PromptHelper.PromptValue[T](String message, Object model, String memberName, T instance)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Microsoft.WingetCreateCLI.PromptHelper.PromptPropertyAndSetValue[T](Object model, String memberName, T instance, Int32 minimum, Object validationModel, String validationName
)
   at Microsoft.WingetCreateCLI.Commands.NewCommand.PromptPackageIdentifier(Manifests manifests)
   at Microsoft.WingetCreateCLI.Commands.NewCommand.Execute()
   at Microsoft.WingetCreateCLI.Program.Main(String[] args)

Environment

Windows: Windows.Desktop v10.0.19043.1566
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.18.2091.0
@ghost ghost added the Needs-Triage label Oct 4, 2022
@Trenly
Copy link
Contributor

Trenly commented Oct 4, 2022

What version of wingetcreate are you using? Have you tried uninstalling and re-installing?

image

@WardenHub
Copy link
Author

Hey @Trenly , thank you for responding.

I'm using Version 1.1.2.0 installed via winget (how else! 👍 )

image

After uninstalling / re-installing I get the same error (nb. before I get the chance to enter values)

Please enter values for the following fields:
The package unique identifier |e.g. Microsoft.VisualStudio|
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.IO.IOException: The handle is invalid.
   at System.ConsolePal.set_CursorVisible(Boolean value)
   at System.Console.set_CursorVisible(Boolean value)
   at Sharprompt.Drivers.DefaultConsoleDriver.Reset()
   at Sharprompt.Drivers.DefaultConsoleDriver.Dispose()
   at Sharprompt.Forms.FormRenderer.Dispose()
   at Sharprompt.Forms.FormBase`1.Dispose()
   at Sharprompt.Prompt.Input[T](InputOptions options)
   at Microsoft.WingetCreateCLI.PromptHelper.PromptValue[T](String message, Object model, String memberName, T instance)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Microsoft.WingetCreateCLI.PromptHelper.PromptPropertyAndSetValue[T](Object model, String memberName, T instance, Int32 minimum, Object validationModel, String validationName)
   at Microsoft.WingetCreateCLI.Commands.NewCommand.PromptPackageIdentifier(Manifests manifests)
   at Microsoft.WingetCreateCLI.Commands.NewCommand.Execute()
   at Microsoft.WingetCreateCLI.Program.Main(String[] args)

@ryfu-msft
Copy link
Contributor

Hey @WardenHub,

The thrown IO exception is coming from System.Console.CursorVisible = true which should rarely happen unless there is something corrupted with your console. I'm not sure if I can help with this but I would try restarting your computer or using different terminals to see if that changes anything. Sorry if that is not helpful but I don't think this is a bug that I can fix in our source code.

@WardenHub
Copy link
Author

Hey @WardenHub,

The thrown IO exception is coming from System.Console.CursorVisible = true which should rarely happen unless there is something corrupted with your console. I'm not sure if I can help with this but I would try restarting your computer or using different terminals to see if that changes anything. Sorry if that is not helpful but I don't think this is a bug that I can fix in our source code.

Hey @ryfu-msft , thank you for replying.

The issue was I was using the powershell ISE (I guess because there's a cursor in the top window and a cursor in the bottom powershell window?) , it works fine on powershell.

So my issue is fixed, perhaps some further info that wingetcreate doesnt run in ISE (can you replicate it in powershell ISE?) or a potential fix can help.

Thanks either way, I have a manifest!

@ryfu-msft
Copy link
Contributor

@WardenHub,

I was able to repro your error when using powershell ISE. Looking into the prompting package that we use they specify their supported platforms and Powershell ISE is not one of them. I will update the README to clarify this. Thanks for bringing this to our attention :)

I will leave this issue open until I make the changes to the README.

mdanish-kh added a commit to mdanish-kh/winget-create that referenced this issue Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants