none
How to solve (Use of unassigned local variable) RRS feed

  • Question

  • Hi,

    I am using Thought.vCards library to generate vCard contact but I am getting the following error:

    Use of unassigned local variable 'vcard_writer'

    Here is my code with thanks...

    vCardPhone vphone1 = new vCardPhone("39753975", vCardPhoneTypes.Cellular);
    vCardPhone vphone2 = new vCardPhone("17681768", vCardPhoneTypes.Work);
    
    vCard my_vcard = new vCard();
    my_vcard.Phones.Add(vphone1);
    my_vcard.Phones.Add(vphone2);
    
    vCardWriter vcard_writer;
    
    vcard_writer.Write(my_vcard, "c:\\temp\\myvcard.vcf");
    


    Wednesday, July 2, 2014 10:24 AM

Answers

  • Check the documentation and samples of the library. Seems that you have to use vCardStandardWriter instead of vCardWriter.

    • Proposed as answer by cheong00Editor Thursday, July 3, 2014 2:31 AM
    • Marked as answer by Jassim Rahma Thursday, July 3, 2014 6:57 AM
    Wednesday, July 2, 2014 12:39 PM

All replies

  • vCardWriter vcard_writer = new vCardWriter();


    jdweng

    Wednesday, July 2, 2014 10:34 AM
  • I did tried that but getting:

    Cannot create an instance of the abstract class or interface

    Wednesday, July 2, 2014 11:13 AM
  • Check the documentation and samples of the library. Seems that you have to use vCardStandardWriter instead of vCardWriter.

    • Proposed as answer by cheong00Editor Thursday, July 3, 2014 2:31 AM
    • Marked as answer by Jassim Rahma Thursday, July 3, 2014 6:57 AM
    Wednesday, July 2, 2014 12:39 PM
  • Agreed. When sample is provided in the project, it's always good to check it first.
    Thursday, July 3, 2014 2:32 AM
    Answerer
  • I am now able to generate the vcf file but I have the following problem

    The file is getting opend in Microsot Outlook but not when sending to any mobile.

    Also when sendng as email, I noticed Outlook will determine vCard and display it in the body as image but my file won't be display as image within the body.. it will only be listed as attachment. however, I have no problem opening in Outlook

    How can I fix this please..

    here is the content of the output file:

    BEGIN:VCARD
    VERSION:3.0
    N:Jassim Rahma
    FN:Jassim Rahma
    ORG:Mesk Holdings
    ADR:;;my address 010;;;;United Kingdom
    EMAIL;TYPE=INTERNET:my personal email 010
    EMAIL;TYPE=INTERNET:my business email 010
    NOTE;ENCODING=QUOTED-PRINTABLE:my remarks comes here....! 010
    TEL;WORK:my telephone 010
    TEL;WORK:my direct 010
    TEL;FAX;WORK:my fax 010
    TEL;CELL:my mobile 1 010
    TEL;CELL:my mobile 2 010
    TEL;WORK:my mobile 3 010
    TEL;WORK:my mobile 4 010
    URL:my website
    END:VCARD
    

    Thursday, July 3, 2014 9:05 AM