2012-12-16 54 views
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. 

回答

2

確保您的插件項目的目標是x86。您的託管項目可能是64位代碼,這會導致框架尋找64位程序集。在Visual Studio 2012這一項目下的屬性 - >建設 - >目標平臺

- Project Properties Screenshot>

+0

我給出了加票,因爲我認爲這讓我朝着正確的方向邁出了一步。但是,現在插件(引用程序集)根本不會加載。 – Ryan

1

我有同樣的錯誤,我正要放棄。我發現的解決方案是,Windows Media Center SDK提供的所​​有說明非常明確地表示要爲x86構建它。解決方案是將其更改爲x64。作爲一個說明,我正在運行一個Windows 7 64位處理器。