Grabacr07 / VirtualDesktop

C# wrapper for the Virtual Desktop API on Windows 11.
MIT License
631 stars 135 forks source link

Exception :: Could not load file or assembly Microsoft.CodeAnalysis, Version=4.0.0.0 ... #82

Closed Anonymous-X2 closed 2 months ago

Anonymous-X2 commented 2 months ago

Created a .NET 6.0 project on Win10 (22H2) using VS22 community (17.11). Although VirtualDesktop.dll works perfectly (awesome), the executable throws the following exception on a virgin Win10 (22H2) machine -> Could not load file or assembly Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. The system cannot find the file specified. The top line of the stack trace reads WindowsDesktop.Interop.CommInterfaceAssemblyBuilder.Compile[Enumerable 1 sources] at WindowsDesktop.Interop.CommInterfaceAssemblyBuilder.CreateAssembly() at ...

Thank You

Minutes later ... As it turns out, my app was not distributing the VirtualDesktop.19045.generated.dll found in the C:\\AppData\Local\grabacr.net\VirtualDesktop\assemblies folder of the development machine. Still trying to figure out what to make of this.

Still more minutes later ... I was able to make VirtualDesktop version 5.0.5 work with 2 mods;

  1. in VirtualDesktop\Interop\ComInterfaceAssemblyBuilder.cs

    if !NETFRAMEWORK

    using System.Runtime.Loader;

    endif

  2. in Virtual Desktop\Properties\AssemblyInfo.cs internal static DirectoryInfo LocalAppData => _localAppData ??= new DirectoryInfo(System.IO.Path.GetFullPath("."));

In the end, not an issue at all.