none
Compilation Error in Outlook Mail App... RRS feed

  • Question

  • Hello,

    I have developed an App and in which I am using a HtmlAgilityPack for parsing. (I have referred this dll in my project). I am getting the below error message when this App is activated in outlook.

    Compiler Error Message: CS0246: The type or namespace name 'HtmlAgilityPack' could not be found (are you missing a using directive or an assembly reference?)

    But when compiling the source code I am not getting any error.

    Can anyone provide a fix for this?

    Thanks

    Monday, September 10, 2012 5:29 AM

Answers

  • This issue has been resolved.. I just created new mail app project and copied my code into that and it started working.

    Thanks Patrick and Thanks Tom for all your support.

    • Marked as answer by Somasundaram.P Friday, September 14, 2012 3:43 AM
    Friday, September 14, 2012 3:43 AM

All replies

  • Hi SSun1979,

    Thanks for posting in the MSDN Forum.

    Would you please show you code snippet here for further research? It's based on my experience that we will finish main business logic under JQuery.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, September 11, 2012 5:12 AM
    Moderator
  • Hello Tom,

    I have pasted the javascript and c# code snippet here...

    I am making an XMLHTTPRequest call to the HTMLParser.aspx.cs page from URLDetails_POC.js file to parse the URL (Say for example : http://blogs.msdn.com/b/officeapps/) and return the Title and Meta Infos of this URL.

    In this case, my expected result should be

    Title : Apps for Office and SharePoint Blog - Site Home - MSDN Blogs

    Meta Description: The official Microsoft blog for developers about apps for Office and SharePoint and the Office Store, from the latest news to developer deep dives.

    URLDetails_POC.js

    var g_oEntities
    var g_oItem;
    
    // Add any initialization logic to this function
    Office.initialize = function () {
        var oMailbox = Office.context.mailbox;
        g_oItem = oMailbox.item;
        g_oEntities = g_oItem.getEntities();
        
        GetUrls();
    }
    
    // Gets instances of the URL entity on the item.
    function GetUrls() {
        // Gets an array of URLs. Each URL is a string.
        var arrUrls = g_oEntities.urls;
        var sURL = 'https://127.0.0.1/URLDetails/URLDetails_POCWeb/Pages/HTMLParser.aspx?';
    
        /*for (var i = 0; i < arrUrls.length; i++) {
            sParams = 'Url=' + arrUrls[0] + '';
            var ReturnValue = fnCallBack(sURL, sParams);
        }*/
    
        sParams = 'Url=' + arrUrls[0] + '';
        var ReturnValue = fnCallBack(sURL, sParams);
        document.getElementById("title").innerHTML ='Title :' + ReturnValue;
    }
    
    function fnCallBack(i_sUrl, i_sParams) {
        try {
            if (window.XMLHttpRequest) {
                xhttp = new window.XMLHttpRequest();
            }
            else {
                xhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xhttp.open("POST", i_sUrl, false);
            xhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xhttp.setRequestHeader("Content-Length", i_sParams.length);
            xhttp.send(i_sParams);
    
            ReturnValue = xhttp.responseText;
            return ReturnValue
        }
        catch (ex) {}
    }

    HTMLParser.aspx.cs

    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using HtmlAgilityPack;
    
    namespace URLDetails_POCWeb.Pages
    {
        public partial class HTMLParser : System.Web.UI.Page
        {
            string sTitle;
            string sMeta;
            protected void Page_Load(object sender, EventArgs e)
            {
                HTMLAgilityParser(Request["Url"]);
            }
    
            public void HTMLAgilityParser(string i_sUrl)
            {
               var oWebGet = new HtmlWeb();
               var oDocument = oWebGet.Load(i_sUrl);
    
               var oMetaTags = oDocument.DocumentNode.SelectNodes("//meta");
               var oTitle = oDocument.DocumentNode.SelectNodes("//title");
    
               if (oTitle != null)
               {
                   foreach (var tag in oTitle)
                   {
                       sTitle = sTitle + ";" + tag.InnerText;
                   }
                   Response.Write(sTitle);
               }
    
             /*  if (oMetaTags != null)
               {
                   foreach (var oTag in oMetaTags)
                   {
                       if (oTag.Attributes["name"] != null)
                       {
                            if (oTag.Attributes["name"].Value.ToLower() == "description")
                                sMeta = oTag.Attributes["content"].Value;
                       }
                   }
               }  */
            }
       } 
    }
    

    Hope you understand my requirement clear.

    Thanks

     

    Tuesday, September 11, 2012 5:33 AM
  • Hi - you are using XMLHttpRequest (XHR) and calling this domain https://127.0.0.1/ (which is localhost) - unless you enable CORS or use another technique for resolving cross domain issues (see this post: http://social.msdn.microsoft.com/Forums/en-US/appsforoffice/thread/4573aa98-2629-447f-852a-9f209842a220) then you'll have issues with the browser preventing cross-domain access unless your app also comes from this domain. Note that use of localhost for anything other than quick debugging is asking for trouble - you are better setting up a test HTTPS server and using it from the get go.

    As an aside note that this code:

            else {
                xhttp
    = new ActiveXObject("Microsoft.XMLHTTP");
           
    }
    Will never be hit on a modern browser (assuming native XHR is enabled) and in the case of apps for Office this will cause your app to fail if executed as we block all ActiveX objects.

    ...pc

    Tuesday, September 11, 2012 3:33 PM
  • Hello Patrick,

    Thanks for your reply...

    Actually I was not facing any cross domain issues and I was able to call the 'https://127.0.0.1/URLDetails/URLDetails_POCWeb/Pages/HTMLParser.aspx?' page using XMLHTTPRequest.

    My problem here is, since I have refered the 'HtmlAgilityPack' dll in HTMLParser.aspx page for parsing, I am getting 'Compilation Error' when calling this page. But when I compile the Visual Studio project it compiles well.

    Thanks

    Thursday, September 13, 2012 3:02 AM
  • Ahh, sorry, I get it now - I'm assuming you've set things up as per standard code behind pages (http://msdn.microsoft.com/en-us/library/015103yb(v=VS.100).aspx) and did you put the agility pack's dll into the website's bin folder? (see the folder structure here: http://msdn.microsoft.com/en-us/library/ex526337(v=vs.100))
    Thursday, September 13, 2012 3:51 AM
  • Yea Patrick.. I have put HtmlAgilityPack.dll into the Website's bin folder...

    Am I missing anything?

    Thursday, September 13, 2012 4:57 AM
  • We'd probably need to look at the full solution to see what is going on - can you strip it down, zip it up and post it somewhere temporarily where we can pick it up?

    BTW - I'm going to be away from the Office till Friday so you may want to hold off till then...

    Cheers..pc

    Thursday, September 13, 2012 5:02 AM
  • Patrick,

    Could you please inform Tom Xu to look into thess issues?

    He also aware of these issues.

    Thanks

    Thursday, September 13, 2012 5:07 AM
  • This issue has been resolved.. I just created new mail app project and copied my code into that and it started working.

    Thanks Patrick and Thanks Tom for all your support.

    • Marked as answer by Somasundaram.P Friday, September 14, 2012 3:43 AM
    Friday, September 14, 2012 3:43 AM