CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

Cannot compile or run under sample projects, "Could not load file or assembly 'System.Runtime' and 'Class not registered'.

Open BradChase2011 opened this issue 2 years ago • 0 comments

Describe the bug Setting up simple UWP or console apps from the given VS templates cannot use CsWinRT. When trying to compile said apps, this error occurs:

Microsoft.AppXPackage.Targets(1437,5): error MSB3816: Loading assembly "C:\User.nuget\packages\microsoft.windows.cswinrt\2.0.4\lib\net6.0\WinRT.Runtime.dll" failed. System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

A certain console app, in the given example, project "ConsoleApplication2" can run but stops immediately after the first call to the class with error:

Exception thrown at 0x00007FFB14B8567C (KernelBase.dll) in ConsoleApplication2.exe: WinRT originate error - 0x80040154 : 'Class not registered'. Exception thrown at 0x00007FFB14B8567C in ConsoleApplication2.exe: Microsoft C++ exception: winrt::hresult_class_not_registered at memory location 0x0000009439D2F058. Unhandled exception at 0x00007FFB14B8567C in ConsoleApplication2.exe: Microsoft C++ exception: winrt::hresult_class_not_registered at memory location 0x0000009439D2F058.

To Reproduce Download the git repository and try to compile each project. For the console app, run it once and let it error out on the immediate call to the AuthoringDemo class library.

https://github.com/BradChase2011/BrokenSampleCsWinRT.git

The solution file is src\BlankApp1\BlankApp1.sln

Expected behavior Expect the apps to compile and be able to use the given CsWinRT class.

Version Info WORKS ON CsWinRT 1.5.0. BROKEN on everything after 1.5.0. CURRENTLY set up on 2.0.4.

Additional context Again they compile and run on 1.5.0 but not above. Just download the git and try to compile to see errors.

BradChase2011 avatar Jan 12 '24 19:01 BradChase2011