我正在尝试首次编写Windows Media Center插件。
该插件将使用外部程序集zeroconfignetservices。我构建了项目,所有内容都正确编译。但是,当我在媒体中心运行应用程序时,事件查看器中会出现以下错误。
Exception System.IO.FileNotFoundException: Could not load file or assembly 'ZeroconfService, Version=0.6.0.0, Culture=neutral, PublicKeyToken=1df4e21661f2383d' or one of its dependencies. The system cannot find the file specified.
但是程序集已加载到GAC中。输出gacutil /l zeroconfservice
:
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.17929
Copyright (c) Microsoft Corporation. All rights reserved.
The Global Assembly Cache contains the following assemblies:
zeroconfservice, Version=0.6.0.0, Culture=neutral, PublicKeyToken=1df4e21661f2
383d, processorArchitecture=x86
Number of items = 1
我还尝试将ZeroconfService.dll的副本放在与媒体中心插件相同的目录中。
我还需要做些什么才能让媒体中心插件看到程序集?
要彻底,编译代码时会出现一个警告。我通常不是.Net开发人员,也不了解警告的细微差别。也许这是相关的?
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "ZeroconfService", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
答案 0 :(得分:2)
确保您的插件项目定位到x86。您的托管项目可能是JIT到64位代码,这将导致框架寻找64位程序集。在Visual Studio 2012中,这在Project Properties-> Build-> Platform Target
下- >
答案 1 :(得分:1)
我遇到了同样的错误,我正要放弃。我找到的解决方案是Windows Media Center SDK提供的所有说明都非常明确地说是为x86构建它。解决方案是将其更改为x64。作为一个说明,我正在运行Windows 7 64位处理器。