keiwando / nativefileso

Unity - Native file dialogs and file type associations on Windows, macOS, iOS and Android
Mozilla Public License 2.0
85 stars 8 forks source link

ArgumentException: Value must be a Com object #6

Open fsol11 opened 2 years ago

fsol11 commented 2 years ago

The following statements generate an error:

 NativeFileSO.shared.OpenFile(SupportedFilePreferences.supportedFileTypes,
    delegate (bool fileWasOpened, OpenedFile file)
          { /* do something */ });

Getting this error:

ArgumentException: Value must be a Com object.
Parameter name: o
System.Runtime.InteropServices.Marshal.ReleaseComObject (System.Object o) (at <231f6c5a042647adb84a9cc42c982c35>:0)
System.Runtime.InteropServices.Marshal.FinalReleaseComObject (System.Object o) (at <231f6c5a042647adb84a9cc42c982c35>:0)
Ookii.Dialogs.VistaFileDialog.RunFileDialog (System.IntPtr hwndOwner) (at <31af777adad04cb788cee0ae18e55ae1>:0)
Ookii.Dialogs.VistaFileDialog.RunDialog (System.IntPtr hwndOwner) (at <31af777adad04cb788cee0ae18e55ae1>:0)
System.Windows.Forms.CommonDialog.ShowDialog (System.Windows.Forms.IWin32Window owner) (at <ee7d35d55c334b8f8f4a9c7bf3b9f8a7>:0)
(wrapper remoting-invoke-with-check) System.Windows.Forms.CommonDialog.ShowDialog(System.Windows.Forms.IWin32Window)
Keiwando.NFSO.NativeFileSOWindows.SelectOpenPathsSync (Keiwando.NFSO.SupportedFileType[] fileTypes, System.Boolean canSelectMultiple, System.String title, System.String directory) (at Assets/NativeFileSO/Scripts/NativeFileSOWindows.cs:126)
Keiwando.NFSO.NativeFileSOWindows.OpenFilesSync (Keiwando.NFSO.SupportedFileType[] fileTypes, System.Boolean canSelectMultiple, System.String title, System.String directory) (at Assets/NativeFileSO/Scripts/NativeFileSOWindows.cs:79)
Keiwando.NFSO.NativeFileSOWindows.OpenFile (Keiwando.NFSO.SupportedFileType[] fileTypes, System.Action`2[T1,T2] onCompletion) (at Assets/NativeFileSO/Scripts/NativeFileSOWindows.cs:42)
Keiwando.NFSO.NativeFileSOMacWin.OpenFile (Keiwando.NFSO.SupportedFileType[] supportedTypes, System.Action`2[T1,T2] onCompletion) (at Assets/NativeFileSO/Scripts/NativeFileSOMacWin.cs:123)
Keiwando.NFSO.NativeFileSO.OpenFile (Keiwando.NFSO.SupportedFileType[] supportedTypes, System.Action`2[T1,T2] onCompletion) (at Assets/NativeFileSO/Scripts/NativeFileSO.cs:146)

No matter what I do, I cannot resolve this. Please help.

Windows Edition: Windows 10 Pro Version: 21H1 OS Build: 19043.1237

keiwando commented 2 years ago

I just tried the sample scene on Windows 10 21H1 19043.1165 in both Unity 2018.3.12f1 and Unity 2021.1.22f1 and cannot reproduce any issues. Opening files works, saving files works, selecting paths works etc.

keiwando commented 2 years ago

I tried it in both of the editors and in a standalone build with 2021.1

fsol11 commented 2 years ago

Thank you very much for testing it. This happened to me after I switched platform to Android which could not be compiled because of lots of errors; so, I switched it back to Windows. Now it could be compiled, but I started getting this weird error and no matter what I did (even reimporting all assets) I could not get rid of this error.

Ultimately I reverted my source code back to the time before switching the platform and this fixed the issue.

I am not sure that it is fixed permanently; because, I will have to switch platforms again at some point to compile for different platforms, and I am not sure if it appears again. When it appears again I can let you know, and you can see it on my computer.