Main Site Documentation

Cobra - Build Error


#1

I’m trying to build a solution for my FEZ Cobra and I’m getting the following error message:

------ Build started: Project: FEZ Cobra METAR Test, Configuration: Debug Any CPU ------
MMP : error MMP0000: CLR_E_FAIL
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

This one’s pretty cryptic … I had no luck searching for information on the forum. Does anyone know what this means?


#2

Not enough information :frowning:

Can you start new project and show us the code you add to give such error


#3

OK, Gus …

Here is the “main” part of the code … it’s really simple and, in fact, it doesn’t even call any of the code in the other file yet.

using System;
using System.Threading;
using System.Net;
using System.IO;
using System.Text;
using System.Xml;

using Microsoft.SPOT;

using NetInfo = Microsoft.SPOT.Net.NetworkInformation;

using METAR;

namespace FEZ_Cobra_Console_Application1
{
    public class Program
    {
        public static void Main()
        {
            // Set up networking ...
            NetInfo.NetworkInterface NI = NetInfo.NetworkInterface.GetAllNetworkInterfaces()[0];
            NI.EnableDhcp();
            Debug.Print("\n\rDCHP - IP Address = " + NI.IPAddress + ", Net Mask = " + NI.SubnetMask + ", Gateway = " + NI.GatewayAddress);
            Debug.Print("DNS Server = " + NI.DnsAddresses[0].ToString() + ", MAC Address = " + NI.PhysicalAddress[0].ToString() + "-" + NI.PhysicalAddress[1].ToString() + "-" + NI.PhysicalAddress[2].ToString() + "-"
                + NI.PhysicalAddress[3].ToString() + "-" + NI.PhysicalAddress[4].ToString() + "-" + NI.PhysicalAddress[5].ToString() + "\n\r");

        }

    }
}

The other part of the code is shown below -

using System;
using System.Threading;
using System.Net;
using System.IO;
//using System.Text;
using System.Xml;
using GHIElectronics.NETMF.IO;

using Microsoft.SPOT;
using Microsoft.SPOT.IO;

//using NetInfo = Microsoft.SPOT.Net.NetworkInformation;

namespace METAR
{
    public class getMetar
    {
        // List of tags to be parsed from the METAR
        public string[] tags = new string[] {
            "location",
            "station_id",
            "observation_time",
            "observation_time_rfc822",
            "weather",
            "temp_f",
            "temp_c",
            "relative_humidity",
            "wind_string",
            "wind_dir",
            "wind_degrees",
            "wind_mph",
            "wind_gust_mph",
            "windchill_f",
            "visibility_mi",
            "pressure_in",
            "dewpoint_f",
            "wind_kt",
            "pressure_mb",
            "icon_url_base",
            "icon_url_name",
            "latitude",
            "longitude",
            };
        //
        //
        public int maxRetries = 5;
        public int retryWait = 100;
        public int requestTimeout = 15000;
        //
        //
        public getMetar()
        {
        }
        //
        //
        private string[,] getWeather(string icao)
        {
            //
            // Used to hold tags and their values obtained from resStream.
            string[,] foundTag = new string[tags.Length, 2];    // Need as many rows as there are strings in the "tags" array.
            // Missing tags will be null.
            //
            // Create the request, response, and stream needed to fetch the METAR.
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.weather.gov/xml/current_obs/" + icao + ".xml");
            request.KeepAlive = true;
            request.ReadWriteTimeout = requestTimeout;
            HttpWebResponse response;
            Stream resStream;
            try
            {
                response = (HttpWebResponse)request.GetResponse();
                resStream = response.GetResponseStream();
            }
            catch
            {
                return foundTag;                    // In case of exception, return null string array.
            }
            //
            // Set up the xml reader.
            XmlReaderSettings ss = new XmlReaderSettings();
            ss.IgnoreWhitespace = true;
            XmlReader xmlr = XmlReader.Create(resStream, ss);
            int k = 0;
            //
            // Loop through the xml-formatted METAR.
            while (!xmlr.EOF)
            {
                try
                {
                    xmlr.Read();
                }
                catch (Exception e)
                {
                    Debug.Print("xml.Read() Exception: " + e.ToString());
                    break;
                }
                if (xmlr.NodeType == XmlNodeType.Element)       // We found a potential tag ...
                {
                    foreach (string tag in tags)                //  so loop through the strings in the "tags" array ...
                    {                                           //  and compare the potential tag to the tags we are looking for.
                        if (xmlr.Name == tag)                   // If we find a match ...                   
                        {
                            foundTag[k, 0] = xmlr.Name;         //  save the tag, ...
                            xmlr.Read();                        //  do another read to fetch the value associated with the tag, ...
                            foundTag[k, 1] = xmlr.Value;        //  and save the value
                            k++;
                        } // End if
                    } // End foreach
                } // End if
            } // End while
            response.Close();
            return foundTag;
        } // End getWeather
        //
        //
        public string[,] getObs(string icao)
        {
            int tries = 0;
            string[,] obs = new string[tags.Length, 2];
            //
            while (tries < maxRetries)
            {
                obs = getWeather(icao);
                if (obs[0, 0] != null)
                    return obs;
                tries++;
                Thread.Sleep(retryWait);
            } // End while
            return obs;
        } // End getObs
    } // End class getMetar
} // End namespace METAR

When I can get the whole thing to build, I’ll add a call to “getObs” to main. :slight_smile: I tested the code from the METAR namespace in .NET on a PC, and it worked just fine. Thanks for taking a look at this …


#4

multi-dimensional arrays are not supported in NETMF. You can use jagged arrays instead.

int [,] //no good
int [][]//this is okay


#5

Also, I have this exact class already written. See: http://files.chrisseto.com/7KE


#6

Thanks Gus … that solved the problem. :-[

Chris - Yes, I know … but it’s more fun for me if I re-invent the wheel. ;D I learn more that way.