0

我第一次尝试编写 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.
4

2 回答 2

2

确保您的插件项目面向 x86。您的托管项目可能是 JIT 到 64 位代码,这将导致框架寻找 64 位程序集。在 Visual Studio 2012 中,在 Project Properties->Build->Platform Target 下

- 项目属性截图>

于 2012-12-17T03:14:24.187 回答
1

我遇到了同样的错误,我正要放弃。我找到的解决方案是 Windows Media Center SDK 提供的所有说明都非常明确地说要为 x86 构建它。解决方案是将其更改为 x64。作为说明,我正在运行 Windows 7 64 位处理器。

于 2015-03-21T23:48:13.907 回答