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

Trying to make an add-in with Visual Basic

Last post 05-14-2012, 4:59 AM by kersal. 1 replies.
Sort Posts: Previous Next
  •  05-09-2012, 12:08 PM 10150

    Trying to make an add-in with Visual Basic

    Hi,
    i'm tried to write an application for Media Center using Visual Basic 2010.
    I wrote a very basic app with a only one code (launch.vb) and a simple MCML page.
    When I try the app the Media Center enter in the application but the page is not displayed.
    The Launch Code is very simple:
    Imports System.Collections.Generic
    Imports Microsoft.MediaCenter.Hosting
    Imports Microsoft.MediaCenter
    Namespace MyProject

        Public Class MyAddIn
            Implements IAddInModule
            Implements IAddInEntryPoint
            Private Shared s_session As HistoryOrientedPageSession
            Public Sub Initialize(appInfo As Dictionary(Of String, Object), entryPointInfo As Dictionary(Of String, Object)) Implements IAddInModule.Initialize

            End Sub
            Public Sub Uninitialize() Implements IAddInModule.Uninitialize
            End Sub
            Public Sub Launch(host As AddInHost) Implements IAddInEntryPoint.Launch
                'Dim myResource As My.Resources.Resources
                'MsgBox(My.Resources.Resources.Prova.Rank)
                If host IsNot Nothing AndAlso host.ApplicationContext IsNot Nothing Then
                    host.ApplicationContext.SingleInstance = True
                End If
                s_session = New HistoryOrientedPageSession()
                Dim app As New MyProject.Application(s_session, host)
                Try
                    Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment.Dialog("Allarm", "it's Work", DialogButtons.Ok, 5, False)
                    s_session.GoToPage("resx://MyProject/MyProject.Resources/Prova")
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
            End Sub
        End Class
    End Namespace


    and the MCL is:
    <Mcml xmlns="http://schemas.microsoft.com/2008/mcml"
          xmlns:cor="assembly://MSCorLib/System">
      <UI Name="Prova">
        <Properties>
          <Color Name="MyColor"
                 Color="White"/>
        </Properties>
        <Locals>
          <cor:String Name="MyString"
                      String="Hello"/>
        </Locals>
        <Rules>
          <Default Target="[MyText.Content]"
                   Value="[MyString]"/>
        </Rules>
        <Content>
          <Text Name="MyText"
                Color="[MyColor]"
                Font="Calibri, 24"/>
        </Content>
      </UI>
    </Mcml>


    The Debug works and devinstall too. When i launch the app from MediaCenter i receive the message "it's Work" but the page "Prova" is not loaded. Why?

    It's the code
    s_session.GoToPage("resx://MyProject/MyProject.Resources/Prova")  right?
    (I have put Prova.mcml on resources.resx)

    Can you help me?
  •  05-14-2012, 4:59 AM 10151 in reply to 10150

    Re: Trying to make an add-in with Visual Basic

    Ok. I did it.
    The problem was on Namespace. I have to put it on root only and not in launch.vb module.

    Now I have another problem:
    MediacenterEnviroment and Playstate are all "friend": how can I use them on VB? I tryed as:
    addin.current.mediacenterenviroment......   but it fails. It's said that i have to make an Istance first, but i cant because is friend.
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems