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

Unable to find type

Last post 07-01-2010, 1:43 PM by homeboy. 5 replies.
Sort Posts: Previous Next
  •  06-20-2010, 12:30 PM 9682

    Unable to find type

    I developed a media center application that works perfectly. However, I needed to change the assembly name and namespace. Rather than doing a find/replace I just decided to create a brand new project and recreate it all from scratch. What's weird is that the new app will not build as I am getting a "Unable to find type" error. The old project builds and runs flawlessly. Can't seem to figure it out. Been researching and playing with it for weeks now. I have a feeling that it has to do with the GAC utility or something along those lines. I really need help with this as I am running short on time. Here is some snippits of code and the errors:

    The Error:

    Error    3    Unable to find type 'DeviceItem'.    C:\Users\Matt\My Projects\Homeboy Software\Apps\Homeboy WMC\Markup\AddDevice.mcml    95    1    HomeboyWMC


    The MCML:

    <Mcml xmlns="http://schemas.microsoft.com/2008/mcml"
          xmlns:cor="assembly://MsCorLib/System"
          xmlns:a="assembly://HomeboyWMC/HomeboyWMC"
          xmlns:c="resx://HomeboyWMC/HomeboyWMC.Resources/Controls"
          xmlns:host="assembly://Microsoft.MediaCenter/Microsoft.MediaCenter.Hosting"
          xmlns:me="Me">

      <UI Name="AddDevice">

        <Properties>
          <a:Application Name="Application" Application="$Required"/>
          <host:PageSession Name="Session" PageSession="$Required"/>
        </Properties>

        <Locals>
          <a:AddDeviceScreen Name="AddDeviceScreen"/>
        </Locals>

        <Content>
          <Panel Layout="Form">

            <Children>

              <c:HeaderText Text="Add Device">
                <LayoutInput>
                  <FormLayoutInput Right="Parent,1,-100"
                                   Top="Parent,0, 50"/>
                </LayoutInput>
              </c:HeaderText>

              <!--
              <me:ActionsMenu Application="[Application]">
                <LayoutInput>
                  <FormLayoutInput Left="Parent,.10"
                                   Top="Parent, .25"/>
                </LayoutInput>
              </me:ActionsMenu>
              -->

              <me:ScreenForm Application="[Application]" AddDeviceScreen="[AddDeviceScreen]">
                <LayoutInput>
                  <FormLayoutInput Left="Parent,.40"
                                   Top="Parent, .25"/>
                </LayoutInput>
              </me:ScreenForm>

              <me:Navigation Application="[Application]" Session="[Session]" AddDeviceScreen="[AddDeviceScreen]">
                <LayoutInput>
                  <FormLayoutInput Right="Parent,.90"
                                   Bottom="Parent, .90"/>
                </LayoutInput>
              </me:Navigation>

            </Children>
          </Panel>
        </Content>

      </UI>

      <UI Name="ActionsMenu">

        <Properties>
          <a:Application Name="Application" Application="$Required"/>
        </Properties>

        <Locals>
          <Command Name="SaveCommand" />
          <Command Name="CancelCommand" />
        </Locals>

        <Rules>
          <Changed Source="[SaveCommand.Invoked]">
            <Actions>
              <Invoke Target="[Application.SaveModem]"/>
            </Actions>
          </Changed>
        </Rules>

        <Content>
          <Panel Layout="VerticalFlow">
            <Children>
              <Text Name="Title" Color="Aqua" Content="ACTIONS" Margins="0,0,0,5" Font="Calibri, 24"></Text>
              <c:SimpleButton Name="SaveButton"  Size="250,51" Command="[SaveCommand]" Text="Save"/>
              <c:SimpleButton Name="CancelButton"  Size="250,51" Command="[CancelCommand]" Text="Cancel"/>
            </Children>
          </Panel>
        </Content>
      </UI>

      <UI Name="ScreenForm">

        <Properties>
          <a:Application Name="Application" Application="$Required"/>
          <a:AddDeviceScreen Name="AddDeviceScreen" AddDeviceScreen="$Required"/>
          <a:DeviceItem Name="DeviceItem"/>
        </Properties>

        <Locals>
          <EditableText Name="DeviceName" Value=""/>
          <EditableText Name="DeviceAddress" Value=""/>
        </Locals>

        <Rules>
          <Binding Source="[NameEditbox.EditableText.Value]" Target="[AddDeviceScreen.Name]" />
          <Binding Source="[AddressEditbox.EditableText.Value]" Target="[AddDeviceScreen.Address]" />
          <Binding Source="[DeviceTypeSpinner.Selected]" Target="[AddDeviceScreen.Type]" />
        </Rules>

        <Content>
          <Panel Layout="VerticalFlow">
            <Layout>
              <FlowLayout Orientation="Vertical"
                          Spacing="10,0"/>
            </Layout>
            <Children>
              <Text Name="NameLabel" Color="White" Content="Provide a unique name for this device (e.g. Living Room Light):" Font="Calibri, 18" MaximumSize="500,100" WordWrap="true"></Text>
              <c:SimpleEditbox Name="NameEditbox" EditableText="[DeviceName]" Size="350,45" FocusOrder="1" />
              <ColorFill Content="AliceBlue" MinimumSize="600,2" MaximumSize="600,2" Alpha=".5" />
              <Text Name="AddressLabel" Color="White" Content="An Insteon address for your device is provided by the manufacturer (e.g. A1A1A1). Enter the address below:" Font="Calibri, 18" MaximumSize="500,100" WordWrap="true"></Text>
              <c:SimpleEditbox Name="AddressEditbox" EditableText="[DeviceAddress]" Size="130,45"/>
              <ColorFill Content="AliceBlue" MinimumSize="600,2" MaximumSize="600,2" Alpha=".5" />
              <Text Name="TypeLabel" Color="White" Content="Select the type of device:" Font="Calibri, 18"></Text>
              <c:SimpleSpinner Name="DeviceTypeSpinner" Model="[DeviceItem.DeviceTypes]"/>
            </Children>
          </Panel>
        </Content>
      </UI>

      <UI Name="Navigation">

        <Properties>
          <a:Application Name="Application" Application="$Required"/>
          <a:AddDeviceScreen Name="AddDeviceScreen" AddDeviceScreen="$Required"/>
          <host:PageSession Name="Session" PageSession="$Required"/>
        </Properties>

        <Locals>
          <Command Name="CancelCommand"/>
          <Command Name="NextCommand"/>
        </Locals>

        <Rules>
          <Changed Source="[CancelCommand.Invoked]">
            <Actions>
              <!--<Invoke Target="[Application.DialogTest]" strClickedText="Cancel"/>-->
              <Invoke Target="[Session!host:HistoryOrientedPageSession.BackPage]"/>
            </Actions>
          </Changed>
          <Changed Source="[NextCommand.Invoked]">
            <Actions>
              <!--<Invoke Target="[Application.DialogTest]" strClickedText="Next"/>-->
              <Invoke Target="[AddDeviceScreen.Next]" app="[Application]" />
            </Actions>
          </Changed>
        </Rules>

        <Content>
          <Panel Layout="HorizontalFlow">
            <Children>
              <c:SimpleButton Name="CancelButton"  Size="110,51" Command="[CancelCommand]" Text="Cancel" />
              <c:SimpleButton Name="NextButton"  Size="86,51" Command="[NextCommand]" Text="Next" />
            </Children>
          </Panel>
        </Content>

      </UI>

    </Mcml>


    The DeviceItem Class:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.MediaCenter.UI;
    using Homeboy.Devices;
    using Homeboy.Protocols;
    using Microsoft.MediaCenter.Hosting;
    using Microsoft.MediaCenter;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Formatters;
    using System.Runtime.Serialization.Formatters.Binary;
    using System.IO;

    namespace HomeboyWMC
    {

        [Serializable]
        public class DeviceItem : ModelItem, ISerializable
        {

            private Device.DeviceType _type;
            private string _name;
            private InsteonAddress _address;
            private Application _app;

            public DeviceItem() { }

            public DeviceItem(SerializationInfo info, StreamingContext ctxt)
            {
                Type = (string)info.GetValue("Type", typeof(string));
                Name = (string)info.GetValue("Name", typeof(string));
                Address = (string)info.GetValue("Address", (typeof(string)));
            }

            public virtual void GetObjectData(SerializationInfo info, StreamingContext ctxt)
            {
                info.AddValue("Type", Type);
                info.AddValue("Name", Name);
                info.AddValue("Address", Address);
            }

            public string Type
            {
                get { return _type.ToString(); }
                set { _type = (Device.DeviceType)Enum.Parse(typeof(Device.DeviceType), value); }
            }

            public string Name
            {
                get { return _name; }
                set { _name = value; }
            }

            public string Address
            {
                get { return _address.ToString(); }
                set { _address = new InsteonAddress(value); }
            }

            public Choice DeviceTypes
            {
                get
                {
                    Choice options = new Choice();
                    List<string> stringItems = new List<string>();
                    stringItems.Add("Light");
                    stringItems.Add("Dimmable Light");
                    stringItems.Add("Computer Bridge");
                    options.Options = stringItems;
                    return options;
                }
            }

        }
    }

  •  06-20-2010, 11:31 PM 9683 in reply to 9682

    Re: Unable to find type

    The only thing that springs to mind is that your error message shows a space in your project name, where your program doesn't.

    If that's not the problem can you ZIP up the entire project and post it somewhere I can download and test here?

    You can email it to me if that's easier.

    Cheers,
    Andrew
  •  06-23-2010, 7:09 PM 9687 in reply to 9683

    Re: Unable to find type

    Hi Andy,

    That definitely isn't the problem. I stripped out all the excess code and kept it down to the basics so that I could reduce it down to one straight forward error. The error I'm getting is:

    Error    68    Unable to find type 'DeviceItem'.    C:\Users\Matt\Documents\Visual Studio 2008\Projects\HomeboyWMC\HomeboyWMC\Markup\Controls\DeviceButton.mcml    13    1    HomeboyWMC

    I zipped the project and uploaded it here: http://www.4shared.com/file/eqZFxNcX/HomeboyWMC.html

    I really appreciate you taking the time to look at it. I can't find anyone else having this problem at all so it's been very frustrating.
  •  06-26-2010, 12:19 PM 9688 in reply to 9687

    Re: Unable to find type

    Okay so I found the problem but don't yet know the right solution. The problem is that in my DeviceItem class I reference an external assembly. I know that in Media Center apps that external assemblies need to have strong name references. The red highlighted lines of code below from my DeviceItem class are causing the problem. I know how to do a strong name reference from MCML code but the external library is not being called from the MCML, but actually from my DeviceItem.cs class. I guess my question now is, how can I reference my external assembly properly from code?

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Formatters;
    using System.Runtime.Serialization.Formatters.Binary;
    using Microsoft.MediaCenter.UI;
    using Homeboy.Devices;
    //using Homeboy.Protocols;

    namespace HomeboyWMC
    {
        [Serializable]
        public class DeviceItem : ModelItem, ISerializable
        {

            private Device.DeviceType _type;
            private string _name;
  •  06-27-2010, 11:39 PM 9689 in reply to 9688

    Re: Unable to find type

    You should just need to reference the assembly in the same way you've referenced your add-in assembly in your MCML.

    Cheers,
    Andrew
  •  07-01-2010, 1:43 PM 9700 in reply to 9689

    Re: Unable to find type

    Thanks a lot Andrew. I will give that a try...
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems