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

Method '[Avalonia.Win32]Avalonia.Win32.Interop.UnmanagedMethods.CoCreateInstance(Guid&,native int,int32,Guid&,object&)' requires marshalling that is not yet supported by this compiler #4541

Closed
FoggyFinder opened this issue Aug 22, 2020 · 3 comments

Comments

@FoggyFinder
Copy link
Contributor

OpenFileDialog/SaveFileDialog/OpenFolderDialog throws exception on CoreRt build

MCVE

  <StackPanel>
    <Button x:Name="selectPathBtn" HorizontalAlignment="Center" 
            Content="Select Path" />
    <TextBox x:Name="pathTxb" />
  </StackPanel>
public class MainWindow : Window
{
    readonly Button selectPathBtn;
    readonly TextBox pathTxb;
    public MainWindow()
    {
        AvaloniaXamlLoader.Load(this);

        selectPathBtn = this.Find<Button>(nameof(selectPathBtn));
        selectPathBtn.Click += SelectPathBtn_Click;
        pathTxb = this.Find<TextBox>(nameof(pathTxb));
    }

    private async void SelectPathBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        var folders = await new OpenFolderDialog()
        {
            Title = "Select folder",
        }.ShowAsync((Window)this.VisualRoot);
        pathTxb.Text = folders;
    }
}

Exception

Unhandled Exception: System.Exception: Method '[Avalonia.Win32]Avalonia.Win32.Interop.UnmanagedMethods.CoCreateInstance(Guid&,native int,int32,Guid&,object&)' requires marshalling that is not yet supported by this compiler.
   at Avalonia.Win32.Interop.UnmanagedMethods.CoCreateInstance(Guid&, IntPtr, Int32, Guid&, Object&) + 0x34
   at Avalonia.Win32.SystemDialogImpl.<>c__DisplayClass2_0.<ShowFolderDialogAsync>b__0() + 0xca
   at System.Threading.Tasks.Task`1.InnerInvoke() + 0x37
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread, ExecutionContext, ContextCallback, Object) + 0x47
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task&, Thread) + 0x161
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xba
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
   at AvaloniaApplicationSample.MainWindow.<SelectPathBtn_Click>d__3.MoveNext() + 0x111
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1) + 0x45
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr, UInt32, IntPtr, IntPtr) + 0x79
   at AvaloniaApplicationSample!<BaseAddress>+0xc926da

Works with .UseManagedSystemDialogs()

@FrankenApps
Copy link

I think that kind of Marshalling simply is not supported yet in CoreRT see here.

What version of Avalonia did you use?

@FoggyFinder
Copy link
Contributor Author

What version of Avalonia did you use?

0.9.x (various)

@FoggyFinder
Copy link
Contributor Author

This is current limitation of Avalonia that related to COM indeed. See no reason to keep it open. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants