winget-create icon indicating copy to clipboard operation
winget-create copied to clipboard

Exception has been thrown by the target of an invocation

Open WardenHub opened this issue 3 years ago • 5 comments

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

WardenHub avatar Oct 04 '22 11:10 WardenHub

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

image

Trenly avatar Oct 04 '22 13:10 Trenly

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)

WardenHub avatar Oct 04 '22 14:10 WardenHub

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.

ryfu-msft avatar Oct 05 '22 17:10 ryfu-msft

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!

WardenHub avatar Oct 06 '22 12:10 WardenHub

@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.

ryfu-msft avatar Oct 07 '22 19:10 ryfu-msft