The Media Center Sandbox

Resources and discussion for developing experiences in the Windows Media Center platform.
Welcome to The Media Center Sandbox Sign in | Join | Help
in Search

Getting media center to load a .net 4 compiled plugin

Last post 07-05-2011, 12:13 AM by AndyC. 3 replies.
Sort Posts: Previous Next
  •  07-29-2010, 2:36 AM 9741

    Getting media center to load a .net 4 compiled plugin

    hi,

    I've just tried upgrading my plugin to .net 4 but I'm having issues getting media center to load the newly compiled .dll file.

    after much searching I found that .net 4 adds things to the gac differently in that it no longer adds it to c:\windows\assembly, but rather c:\windows\microsoft .net\assembly\gac_msil, I also found that the normal gacutil won't perform this correctly, so you need to use the newer gacutil provided with the .net 4 installation. I have used this new gacutil and can see my plugin in this new assembly location, but whenever I try and start windows media center my plugin crashes saying that it can't find my assembly!

    do I need to update my registration.xml in any way? or is there a trick to getting media center to look in the new gac? from what I can see the version is correct and the public key is the same so I'm at a loss.

    if anyone has any suggestions I'd be extremely grateful.

    regards,

    ~ evorgevol
  •  07-31-2010, 10:47 AM 9744 in reply to 9741

    Re: Getting media center to load a .net 4 compiled plugin

    Sounds like this is a limitation of the way the Media Center loads your file. Try temporarily putting a copy of your DLL into C:\Windows\ehome and see if it's picked up.

    Cheers,
    Andrew
  •  06-29-2011, 10:30 AM 10116 in reply to 9744

    Re: Getting media center to load a .net 4 compiled plugin

    I just went down the same route as evorgevol while attempting to migrate one of our plug-ins to .NET 4.0, with exactly the same results.

    I've now tried Andy's suggestion above, and the DLL can at least now be found. Unfortunately, Media Center reports:

    InnerException System.BadImageFormatException: Could not load file or assembly 'Amulet.EPG, Version=3.0.4.0, Culture=neutral, PublicKeyToken=c364ab31ccee11cf' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

    So essentially, unless there is some trick that can be played with ehExtHost.exe.config to get it to run inside the .NET 4.0 runtime (while still compiled for 3.5), it looks like this just won't work.

    And even if there is a way to persuade it to work, there may be negative implications for older 3.5 apps, given that the same ehExtHost.exe is used for them all.

    Anyone else experimented with this and found a way through?

    Eddy
  •  07-05-2011, 12:13 AM 10117 in reply to 10116

    Re: Getting media center to load a .net 4 compiled plugin

    Have you tried application domains? I'm not sure, but it may be possible to have different versions of the framework in different domains.

    Another approach you could try would be to put your 4.0 code into an out-of-process EXE and communicate using sockets (ugly, but if you absolutely need 4.0 then it should work).

    Cheers,
    Andrew
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems