none
call c# dll from Outlook Addin. RRS feed

  • Question

  • Hello

    I have  c# dll for access to database for all my proyects.  I want use this dll for Outlook AddIn project.

    I make a Outlook AddIn project, when I instantiate the  dll, this not work fine, no execute this code part , no error. This occur when deploy the addIn.

    When i run with vs2010 AddIn works fine.

    How to implement this.

    Regards

    Thursday, July 18, 2013 3:10 PM

Answers

  • add global try catch in code that invokes functionality from that dll and show in messagebox errors - most probably you get exception that is uncaught by your code.
    Friday, July 19, 2013 8:03 AM
  • Hello

    I had other soluction, it works fine for me.

    The solution it's share de C# class of DLL with function "link" the vs2010.

    You know when you add exist class in yours project I link the file, this functionality permit share the code in diferent project and works fine wih TFS.

    Its this a good idea or not?

    Regards

    Monday, July 22, 2013 7:19 AM

All replies

  • Please provide enough information.

    Is this a managed code DLL or a COM DLL?

    What Framework version, and if Framework 4 or above are you embedding a PIA for the DLL if it's a COM DLL or referencing the DLL, and are you deploying it with the installer?

    Show the code you use to instantiate an instance of the DLL and how you call into it.


    Ken Slovak MVP - Outlook

    Thursday, July 18, 2013 5:20 PM
    Moderator
  • Thank's Ken.

    It's a DLL.

    .NET Framewor 4

    Intance DLL

    xmlFunctionality xml = new xmlFunctionality();

    xml.readXmlFile(@"J:\GesDocum\PiedeConfig\Config.xml");
    String production = xml.readXmlNode("//PIEDE/Production");
    MessageBox.Show("Afer xmlFunctionality: " + production);

    DLL

    public class xmlFunctionality
        {
            XmlDataDocument xmlDocument = new XmlDataDocument();

            // Metodo para cargar el fichero XML,
            // pasando como parametro el path donde se encuentra el fichero.
            public void readXmlFile(string XmlFile)
            {
                xmlDocument.Load(XmlFile);
            }

            // Metodo para obtener el valor de un elemento concreto.
            // Como parametro pasaremos el camino completo dentro del fichero XML (//PIEDE//basededatosTest)
            public string readXmlNode(string nodename)
            {
                XmlNodeList nodeList = xmlDocument.SelectNodes(nodename);
                return nodeList.Item(0).InnerText;           
            }

            // Metodo para obtener una lista con todos los nodos que coincidan
            // con el parametro pasado
            public XmlNodeList readXmlNodeList(string nodename)
            {
                XmlNodeList readXmlNodeList = xmlDocument.GetElementsByTagName(nodename);
                return readXmlNodeList;
            }

            // Metodo para obtener el valor de un elemento concreto.
            // Como parametro pasaremos el nombre de la etiqueta que contiene el valor buscado (basededatosTest).
            //[ComVisible(true)]
            public string readXMLElement(string elementName)
            {
                XmlNodeList element = xmlDocument.GetElementsByTagName(elementName);
                return element.Item(0).InnerText;
            }
        }

    Regards

    Friday, July 19, 2013 7:09 AM
  • add global try catch in code that invokes functionality from that dll and show in messagebox errors - most probably you get exception that is uncaught by your code.
    Friday, July 19, 2013 8:03 AM
  • Have you stepped the code in the debugger to see what's failing and why? For example, is the "xml" object null after you instantiate it with new?

    Is the DLL deployed where the code can find it?

    Is it registered on the development machine and not when deployed?


    Ken Slovak MVP - Outlook

    Friday, July 19, 2013 5:40 PM
    Moderator
  • Hello

    I had other soluction, it works fine for me.

    The solution it's share de C# class of DLL with function "link" the vs2010.

    You know when you add exist class in yours project I link the file, this functionality permit share the code in diferent project and works fine wih TFS.

    Its this a good idea or not?

    Regards

    Monday, July 22, 2013 7:19 AM