I am using Consuming Nouget Package
VirtualDesktop in my desktop application. When I call
VirtualDesktop.IsSupported
then it returns True. But When I call
VirtualDesktop.IsPinned(handle)
it returns following exception.
Exception:Empty path name is not legal. (Parameter 'path')
StackTrace: at System.IO.Strategies.FileStreamHelpers.ValidateArguments(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at Roslyn.Utilities.StandardFileSystem.OpenFile(String filePath, FileMode mode, FileAccess access, FileShare share)
at Roslyn.Utilities.CommonCompilerFileSystemExtensions.OpenFileWithNormalizedException(ICommonCompilerFileSystem fileSystem, String filePath, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
at WindowsDesktop.Interop.ComInterfaceAssemblyBuilder.<>c.<Compile>b__14_2(Assembly x)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)
at WindowsDesktop.Interop.ComInterfaceAssemblyBuilder.Compile(IEnumerable`1 sources)
at WindowsDesktop.Interop.ComInterfaceAssemblyBuilder.CreateAssembly()
at WindowsDesktop.Interop.ComInterfaceAssemblyBuilder.GetAssembly()
at WindowsDesktop.VirtualDesktop.InitializeCore()
at WindowsDesktop.VirtualDesktop.FromHwnd(IntPtr hWnd)
at MyProject.DB.DTOs.ActiveApplication.<>c__DisplayClass138_0.<AssignVirtualDesktop>b__0() in D:/ProjectPath
What I have tried:
It works fine on my Dev machine but failed on all production machines. When I installed Dev tools (Visual studio 2022), it works fine too on that machine.
I am making executable by
publish option available in VS-2022.
Note: I have found that When I
publish by checking option
Produce Single File then this exception occurs. If unchecked this option, then works fine but there is list of files are generated.
How to resolve it with Produce Single File option selected ???