简体   繁体   English

无法加载文件或程序集“System.Private.CoreLib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e”

[英]Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'

I am trying to run this code:我正在尝试运行此代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Bluetooth;
using Windows.Devices.Enumeration;

namespace Bluetooth_sharp
{
    internal class Program
    {
        static void Main(string[] args)
        {
            
            // Query for extra properties you want returned
            string[] requestedProperties = { "System.Devices.Aep.DeviceAddress", "System.Devices.Aep.IsConnected" };

            DeviceWatcher deviceWatcher =
                        DeviceInformation.CreateWatcher(
                                BluetoothLEDevice.GetDeviceSelectorFromPairingState(false),
                                requestedProperties,
                                DeviceInformationKind.AssociationEndpoint);

            // Register event handlers before starting the watcher.
            // Added, Updated and Removed are required to get all nearby devices
            deviceWatcher.Added += DeviceWatcher_Added;
            deviceWatcher.Updated += DeviceWatcher_Updated;
            deviceWatcher.Removed += DeviceWatcher_Removed;

            // EnumerationCompleted and Stopped are optional to implement.
            deviceWatcher.EnumerationCompleted += DeviceWatcher_EnumerationCompleted;
            deviceWatcher.Stopped += DeviceWatcher_Stopped;

            // Start the watcher.
            deviceWatcher.Start();

            while (true)
            {
                Console.WriteLine("Press any key . . .");
                Console.ReadKey();
            }
        }

        private static void DeviceWatcher_Stopped(DeviceWatcher sender, object args)
        {
            //throw new NotImplementedException();
        }

        private static void DeviceWatcher_EnumerationCompleted(DeviceWatcher sender, object args)
        {
            //throw new NotImplementedException();
        }

        private static void DeviceWatcher_Removed(DeviceWatcher sender, DeviceInformationUpdate args)
        {
            //throw new NotImplementedException();
        }

        private static void DeviceWatcher_Updated(DeviceWatcher sender, DeviceInformationUpdate args)
        {
            //throw new NotImplementedException();
        }

        private static void DeviceWatcher_Added(DeviceWatcher sender, DeviceInformation args)
        {
            Console.WriteLine(args.Name);
            //throw new NotImplementedException();
        }
    }

}

This is sample code which I got from: https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client这是我从中获得的示例代码: https ://learn.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client

But when I execute it I get the following error:但是当我执行它时,出现以下错误:

'Bluetooth-sharp.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Bluetooth-sharp.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Users\elect\source\repos\Bluetooth-sharp\Bluetooth-sharp\bin\Debug\Bluetooth-sharp.exe'. Symbols loaded.
'Bluetooth-sharp.exe' (CLR v4.0.30319: Bluetooth-sharp.exe): Loaded 'C:\windows\SysNative\WinMetadata\Windows.Devices.winmd'. Module was built without symbols.
'Bluetooth-sharp.exe' (CLR v4.0.30319: Bluetooth-sharp.exe): Loaded 'C:\Users\elect\source\repos\Bluetooth-sharp\Bluetooth-sharp\bin\Debug\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

The program '[10840] Bluetooth-sharp.exe' has exited with code 4294967295 (0xffffffff).

I was following this tutorial , but he didn't encounter this error.我正在按照本教程进行操作,但他没有遇到此错误。 One thing I did differently is that his System.Runtime.WindowsRuntime.dll is in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5 , while I got mine from C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\runtime.win10-arm.microsoft.netcore.universalwindowsplatform\6.2.14\runtimes\win10-arm\lib\uap10.0.15138 because I only had XML files in the other folder.我做的不同的一件事是他的System.Runtime.WindowsRuntime.dllC:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5中,而我是从C:\Program Files ( x86)\Microsoft SDKs\UWPNuGetPackages\runtime.win10-arm.microsoft.netcore.universalwindowsplatform\6.2.14\runtimes\win10-arm\lib\uap10.0.15138因为我在另一个文件夹中只有 XML 文件。

Nothing I could find with Google was able to fix the problem.我在 Google 上找不到的任何东西都无法解决问题。

In your issue, what happened was that .NET native compilation was skipped in storage, resulting in an invalid bundle because the declared dependencies did not match the contents of the bundle.在您的问题中,发生的情况是 .NET 本机编译在存储中被跳过,导致捆绑包无效,因为声明的依赖项与捆绑包的内容不匹配。 You need to recheck the version of the dependencies you are using.您需要重新检查您正在使用的依赖项的版本。 Also, I noticed that "The program '[10840] Bluetooth-sharp.exe' has exited with code 4294967295 (0xffffffff)."另外,我注意到“程序‘[10840] Bluetooth-sharp.exe’已退出,代码为 4294967295 (0xffffffff)。” This is because the corresponding file was not found, you'd better change to the same path as your sample code.这是因为没有找到对应的文件,最好改成和你的示例代码一样的路径。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集“系统,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”或其依赖项之一 - Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies FileNotFoundException-无法加载文件或程序集'System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089' - FileNotFoundException - Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 无法加载文件或程序集'System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 561934e089'或其依赖项之一 - Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=561934e089' or one of its dependencies 无法加载文件或程序集'System.Web.Http.WebHost,版本= 4.0.0.0,区域性=中性,PublicKeyToken - Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken 无法加载文件或程序集“System.Web.Extensions,版本=4.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35” - Could not load file or assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 无法加载文件或程序集'System.Data.Linq,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'或其依赖项之一 - Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies 无法加载文件或程序集“System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”或其依赖项之一 - Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies 无法加载文件或程序集“System.Web.Mvc,版本=4.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35” - Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 无法加载文件或程序集“System.IO,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一 - Could not load file or assembly 'System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies 无法加载文件或程序集“System.Net.Http,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a” - Could not load file or assembly "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM