Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. MCE SDK 2005 problem

MCE SDK 2005 problem

Scheduled Pinned Locked Moved C#
helpcomtutorialquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Oguz Mazlum
    wrote on last edited by
    #1

    Hi, I was reading the MCE SDK 2005, there is an example of MediaState, I’ve compiled it to test it on my MCE. I had to add the needed register component that i found on the SDK help file. When i run the app, it does not get any information from the MediaCenter. What could be wrong? I think the COM object is not working properly because i cant read any information of MCE. Does anyone have a clue? Greetings.

    H 1 Reply Last reply
    0
    • O Oguz Mazlum

      Hi, I was reading the MCE SDK 2005, there is an example of MediaState, I’ve compiled it to test it on my MCE. I had to add the needed register component that i found on the SDK help file. When i run the app, it does not get any information from the MediaCenter. What could be wrong? I think the COM object is not working properly because i cant read any information of MCE. Does anyone have a clue? Greetings.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      In order to diagnose and recommend solutions to your problem, you need to be more specific. What exception did you get? What was the stack trace of the exception? What was the detailed message? If you're doing this from managed code, you need to include the interop assembly for the COM object that was generated automatically by VS.NET (or tlbimp.exe). This is usually named "Interop.Something.dll". This must be resolvable. If you're not doing this with managed code - specifically C# - then you're in the wrong forum and need to choose the appropriate forum for your problem. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

      O 1 Reply Last reply
      0
      • H Heath Stewart

        In order to diagnose and recommend solutions to your problem, you need to be more specific. What exception did you get? What was the stack trace of the exception? What was the detailed message? If you're doing this from managed code, you need to include the interop assembly for the COM object that was generated automatically by VS.NET (or tlbimp.exe). This is usually named "Interop.Something.dll". This must be resolvable. If you're not doing this with managed code - specifically C# - then you're in the wrong forum and need to choose the appropriate forum for your problem. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

        O Offline
        O Offline
        Oguz Mazlum
        wrote on last edited by
        #3

        I didnt get any exception, the code gives no errors. I wrote i managed code. I read in the SDK help file that i need to register the MSASState.dll with [regasm.exe MSASState.dll /codebase] and placed the following registry [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469} \Implemented Categories\{FCB0C2A3-9747-4c95-9d02-820AFEDEF13F}] @="Media Status Sink" This was needed to read mediastate information about the Media Center. I wrote a simple code that checks if the MCE is active or not active. I have loaded the MediaState.dll in to my app. .... MediaState mediaState = new MediaState(); // hook up events mediaState.MediaCenter.Started += new EventHandler(OnMediaCenterStarted); mediaState.MediaCenter.VolumeChanged += new EventHandler(MediaCenter_VolumeChanged); // Start receiving media state information mediaState.Connect(); if (mediaState.MediaCenter.Active) { label8.Text = "Media Center is Active"; } else { label8.Text = "Media Center is NOT Active"; } .... I'm getting that the status is NOT active. I have tried the mediastatedisplay example that came with the MCE SDk 2005 on my MCE and that also cant read any information about MCE while it is running. I have no idea what could be wrong.

        H 1 Reply Last reply
        0
        • O Oguz Mazlum

          I didnt get any exception, the code gives no errors. I wrote i managed code. I read in the SDK help file that i need to register the MSASState.dll with [regasm.exe MSASState.dll /codebase] and placed the following registry [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469} \Implemented Categories\{FCB0C2A3-9747-4c95-9d02-820AFEDEF13F}] @="Media Status Sink" This was needed to read mediastate information about the Media Center. I wrote a simple code that checks if the MCE is active or not active. I have loaded the MediaState.dll in to my app. .... MediaState mediaState = new MediaState(); // hook up events mediaState.MediaCenter.Started += new EventHandler(OnMediaCenterStarted); mediaState.MediaCenter.VolumeChanged += new EventHandler(MediaCenter_VolumeChanged); // Start receiving media state information mediaState.Connect(); if (mediaState.MediaCenter.Active) { label8.Text = "Media Center is Active"; } else { label8.Text = "Media Center is NOT Active"; } .... I'm getting that the status is NOT active. I have tried the mediastatedisplay example that came with the MCE SDk 2005 on my MCE and that also cant read any information about MCE while it is running. I have no idea what could be wrong.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          When you use /codebase with regasm.exe the path to the assembly is registered. This means your assembly must be in the same place. If you don't use /codebase, you must add the assembly to the GAC (requires it to be strong-named, which is always a good idea anyway). So the code above is in the assembly exposed to COM (a COM-Callable Wrapper, or CCW)? I've not seen this example but I do know a lot about COM and know that COM won't load an EXE. Since this is obviously code for a Windows Forms components (well, judging by _label8_), I know that the Media Center won't load it. The component category that you implenented is used by the Media Center to figure out which components to load. Somewhere, then, you need to get the running instance of your component that you registered. Have you followed the SDK sample exactly? This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

          O 1 Reply Last reply
          0
          • H Heath Stewart

            When you use /codebase with regasm.exe the path to the assembly is registered. This means your assembly must be in the same place. If you don't use /codebase, you must add the assembly to the GAC (requires it to be strong-named, which is always a good idea anyway). So the code above is in the assembly exposed to COM (a COM-Callable Wrapper, or CCW)? I've not seen this example but I do know a lot about COM and know that COM won't load an EXE. Since this is obviously code for a Windows Forms components (well, judging by _label8_), I know that the Media Center won't load it. The component category that you implenented is used by the Media Center to figure out which components to load. Somewhere, then, you need to get the running instance of your component that you registered. Have you followed the SDK sample exactly? This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

            O Offline
            O Offline
            Oguz Mazlum
            wrote on last edited by
            #5

            My friend :) The sample code I wrote and the sample came with the SDK is not executed by MCE. It's an windowsform based app that can read status information about the MCE. My example is not integrated in to MCE, it's running beside MCE on the background. To read status information about MCE i had to register the MSASstate COM sink. This component delivers the mediastatus about the MCE. I have checked the registery after the (regasm.exe MSASState.dll /codebase) and found the following registry items. [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}] @="MSASState.MediaStatusSink" [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}\Implemented Categories] [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}] [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}\InprocServer32] @="mscoree.dll" "ThreadingModel"="Both" "Class"="MSASState.MediaStatusSink" "Assembly"="MSASState, Version=1.0.1740.26563, Culture=neutral, PublicKeyToken=a097a53b6b26c493" "RuntimeVersion"="v1.0.3705" "CodeBase"="file:///C:/WINDOWS/system32/MSASState.DLL" [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}\InprocServer32\1.0.1740.26563] "Class"="MSASState.MediaStatusSink" "Assembly"="MSASState, Version=1.0.1740.26563, Culture=neutral, PublicKeyToken=a097a53b6b26c493" "RuntimeVersion"="v1.0.3705" "CodeBase"="file:///C:/WINDOWS/system32/MSASState.DLL" [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}\ProgId] @="MSASState.MediaStatusSink" If i'm correct the settings are correct according the SDK. I have three framework versions on my MCE. v1.0/v1.1/v2.0Beta i have registered with all versions the MSASState.dll and its still not working. The problem is that the MSASState.dll does not deliver any information about the MCE. Where can i see that the MSASState.dll is running? I can't find it in the Component Services.

            H 1 Reply Last reply
            0
            • O Oguz Mazlum

              My friend :) The sample code I wrote and the sample came with the SDK is not executed by MCE. It's an windowsform based app that can read status information about the MCE. My example is not integrated in to MCE, it's running beside MCE on the background. To read status information about MCE i had to register the MSASstate COM sink. This component delivers the mediastatus about the MCE. I have checked the registery after the (regasm.exe MSASState.dll /codebase) and found the following registry items. [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}] @="MSASState.MediaStatusSink" [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}\Implemented Categories] [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}] [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}\InprocServer32] @="mscoree.dll" "ThreadingModel"="Both" "Class"="MSASState.MediaStatusSink" "Assembly"="MSASState, Version=1.0.1740.26563, Culture=neutral, PublicKeyToken=a097a53b6b26c493" "RuntimeVersion"="v1.0.3705" "CodeBase"="file:///C:/WINDOWS/system32/MSASState.DLL" [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}\InprocServer32\1.0.1740.26563] "Class"="MSASState.MediaStatusSink" "Assembly"="MSASState, Version=1.0.1740.26563, Culture=neutral, PublicKeyToken=a097a53b6b26c493" "RuntimeVersion"="v1.0.3705" "CodeBase"="file:///C:/WINDOWS/system32/MSASState.DLL" [HKEY_CLASSES_ROOT\CLSID\{380AA9F1-5047-40D0-8BE9-18AB489CA469}\ProgId] @="MSASState.MediaStatusSink" If i'm correct the settings are correct according the SDK. I have three framework versions on my MCE. v1.0/v1.1/v2.0Beta i have registered with all versions the MSASState.dll and its still not working. The problem is that the MSASState.dll does not deliver any information about the MCE. Where can i see that the MSASState.dll is running? I can't find it in the Component Services.

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              The fact that you have to register a component category (which you can do programmatically when regasm.exe is called on your assembly; read about the ComRegisterFunctionAttribute and ComUnregisterFunctionAttribute classes in the .NET Framework - which run in addition to the normal registration) means that some COM client is going to use ICatInformation::EnumClassesOfCategories (or equivalent) to get COM servers implementing supported interfaces. Your DLL is one such COM server. The MSAS is a COM server that is actually querying for this information about implementations such as your state service. BTW - you should not be installing your files into the system directory. Since your using regasm.exe you can install them anyway (but keep them there), or - better yet (recommended) sign the assembly (more secure anyway) and install it into the GAC using gacutil.exe and then use regasm.exe MSASState.dll (no /codebase, which tells the mscoree.dll shim to look in the GAC). It's your job as the developer of this sink to communicate your data to whatever client you want. With .NET, your best approach is to use .NET Remoting. If you haven't already, read Retrieving Media Status[^] in the SDK that explains how the MSAS loads the sinks (your assembly, acting as a COM server indirectly through the mscoree.dll shim). And creating a Windows Forms application that references this assembly won't do any good - you need to reference the object that MSAS has loaded. This is where .NET Remoting comes in. You need to communicate this data between the AppDomain that was created for your sink and the AppDomain for your Windows Forms application (using statis will not work - each AppDomain is a separate context). Read the .NET Remoting Overview[^]. There's also several good articles on this site about .NET Remoting, as well as a couple good books like "Microsoft .NET Remoting" from Microsoft Press[

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups