PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2013 Separate Imports for different forms/functions - Possible?-VBForums
Results 1 to 3 of 3

Thread: Separate Imports for different forms/functions - Possible?

  1. #1

    Thread Starter
    Join Date
    Sep 2013

    Separate Imports for different forms/functions - Possible?

    Hi guys, I've had a quite laborious Window application which dealt with datasets and parsing strings extensively.

    In recent times, I tried to implement additional data into the datasets using ITextSharp from separate pdf files.

    Now, if I added the ITextSharp .dll files into the current Main Form, and after importing the references to it, it screws my current program with errors like:

    Error 5 'Path' is ambiguous, imported from the namespaces or types 'iTextSharp.text.pdf.parser, System.IO'. C:\Users\Vizier87\Documents\Visual Studio 2013\Projects\Coriumerus v1.11\Coriumerus\Form1.vb 387 83 Coriumerus v1.11
    So I made a different Window Form within the project, and added the references to it, and the program kinda worked.

    Now I know this is pretty a sloppy solution. Is there a neater way to have like separate functions which don't need forms or something like that? Or having "Imports" which doesn't affect the current program?


  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: Separate Imports for different forms/functions - Possible?

    Firstly, you should really read this:

    Referencing Assemblies and Importing Namespaces

    As for the issue, it's just a name clash, i.e. you have two types with the same name for which you have imported their namespace. All you have to do is disambiguate them somehow. There are various ways to do that.

    One option would be to remove the import for the System.IO namespace and then qualify all types from that namespace. The System namespace will still be imported so you only need the IO, e.g. IO.Path.GetFileName. That may be annoying if you use types from that namespace a lot but at least it's only three extra characters each time.

    Another option is to define Path as an alias: Code:
    1. Import Path = iTextSharp.text.pdf.parser.Path
    After that, any use of Path unqualified will be interpreted as that type and you will need to use IO.Path to refer to that class.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Join Date
    Sep 2013

    Re: Separate Imports for different forms/functions - Possible?

    Thanks John. I'll be ruminating on your article so that I'll get a clearer picture.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width