Attachment Encoder and Decoder - InfoPath Dev
in

InfoPath Dev

Attachment Encoder and Decoder

Last post 02-09-2010 11:41 PM by Lawson. 25 replies.
Page 1 of 2 (26 items) 1 2 Next >
Sort Posts: Previous Next
  • 02-05-2010 05:25 PM

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Attachment Encoder and Decoder

    Hello Everybody,

    I just started using InfoPath about a month ago. I am trying to implement the Microsoft encoder and decoder for form attachments found at the following website http://support.microsoft.com/kb/892730.

    However, I do not have Microsoft Visual Studio .Net. I tried to implement the code in an InfoPath 2007 form, but I received an enormous amount of errors. Does anybody have a form with this code imbedded so I can see how you did it? Or can somebody take a look at my form to help me make it work.

    My email address is [email protected]. If you email me, I will give you a copy of my form or look at your form.

    Thank you,

    Lawson

     

     

  • 02-09-2010 11:27 AM In reply to

    Re: Attachment Encoder and Decoder

    Hi -- This sample code is for the IP 2003 Object model. You can change your form to use the 2003 OM (under Tools / Form Options / Programming) and you may find you have less errors to work through.

    Hilary Stoupa

  • 02-09-2010 11:40 AM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    Hi Hilary,

    I switched over to the 2003 compatible Object model. This cut my errors in half. However, I still get the following six errors.

    Error      1              The type or namespace name 'Encoder' does not exist in the namespace 'InfoPathAttachmentEncoding' (are you missing an assembly reference?)           

    Error      2              The type or namespace name 'Encoder' does not exist in the namespace 'InfoPathAttachmentEncoding' (are you missing an assembly reference?)           

    Error      3              The type or namespace name 'Decoder' does not exist in the namespace 'InfoPathAttachmentEncoding' (are you missing an assembly reference?)           

    Error      4              The type or namespace name 'Decoder' does not exist in the namespace 'InfoPathAttachmentEncoding' (are you missing an assembly reference?)

    Error      5              The best overloaded method match for 'string.EndsWith(string)' has some invalid arguments    

    Error      6              Argument '1': cannot convert from 'char' to 'string'          

     Do you think this is because I am not using Visual Studio .Net 2005? 

    Thanks for your help,

    -Lawson

     

  • 02-09-2010 12:44 PM In reply to

    Re: Attachment Encoder and Decoder

    You are using VSTA, right? That ships with IP 2007? So no, using Visual Studio instead won't make a difference.

    You need to add a reference to your InfoPathAttachmentEncoding class. This link has some directions for how to do that.

    As to your last two errors -- I searched the page with the code sample for 'string.EndsWith(string)' and can't find it -- where is that line in the sample? Same question for the last error....

    Hilary Stoupa

  • 02-09-2010 12:58 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    Error 5 and Error 6 refers to fullFileName.EndsWith(Path.DirectorySeparatorChar)in the attachment decoder.

  • 02-09-2010 01:31 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    Thank you for that article on references. I looked up encoder class and decoder class and they belong to a namespace called System.text. I tried to add this reference, but I do not have it in my library. Is there any way to get it of the Internet, or do I need to get visual studio .Net 2005?

  • 02-09-2010 01:54 PM In reply to

    Re: Attachment Encoder and Decoder

    Can you just zip up your template and code files and attach them to a post? Under the Options tab you can attach a file.

    Hilary Stoupa

  • 02-09-2010 02:58 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Sure, I have attached the zipped file.

    Thanks for all of your help

    -Lawson

  • 02-09-2010 03:55 PM In reply to

    Re: Attachment Encoder and Decoder

    Can you also attach your code files? Looks like they can be found here:

    C:\Users\Lawson\Documents\InfoPath Projects\AttachmentEncoding8

    Just zip up the whole folder.

    As far as adding the reference goes, you need to add a reference to your new InfoPathAttachmentEncoding class that you created while following the code sample....probably under the Projects tab when you add a reference to the solution. This link may help you....

    Hilary Stoupa

  • 02-09-2010 05:50 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Ok, I'll look at that and try to add the reference. I have attached the code files.

    Once again, thank you for all your help.

    -Lawson

  • 02-09-2010 06:07 PM In reply to

    Re: Attachment Encoder and Decoder

     It looks like there's a bug in Microsoft's code sample.

    They have this line:

    InfoPathAttachmentEncoding.Encoder myEncoder = new InfoPathAttachmentEncoding.Encoder(fileName);
    But the class is called InfoPathAttachmentEncoder, not just Encoder. Try this instead:
     InfoPathAttachmentEncoding.InfoPathAttachmentEncoder myEncoder = new InfoPathAttachmentEncoding.InfoPathAttachmentEncoder(fileName);
    And try changing this:
    fullFileName.EndsWith(Path.DirectorySeparatorChar)
    to this:
    fullFileName.EndsWith(Path.DirectorySeparatorChar.ToString())
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-09-2010 06:09 PM In reply to

    Re: Attachment Encoder and Decoder

    I can see the problem, don't bother trying to add references -- I'll have this posted back here shortly...

    Hilary Stoupa

  • 02-09-2010 06:16 PM In reply to

    Ah, I see Jimmy already posted the details about the issue! Here is a zip with the modified code. I've also included a Word docx with some screenshots and info to help you get your form template repointed to the corrected code module.

    Hilary Stoupa

  • 02-09-2010 06:28 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Re: Attachment Encoder and Decoder

    The decoder and encoder classes belong to the System.Text Namespace. I took your suggestion and tried to add the reference. However, the System.Text Namespace does not exist. I found many different system namespaces, but no system.text.  This is pretty baffling because from everything I’ve read about VSTA 2.0 leads me to believe this reference should be available.

    Do you have any suggestions?

    Is it possible to download this particular Namespace from somewhere?

    -Lawson

     

  • 02-09-2010 06:40 PM In reply to

    Re: Attachment Encoder and Decoder

     I already told you how to fix the problem and Hilary has modified your code to work correctly.  It has nothing to do with the System.Text namespace.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 2 (26 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.