CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2010
    Posts
    23

    Add-in reference programmatically

    hey

    ive been on this for couple hours!!
    i searched google but didnt find some useful thing about adding reference programmatically!

    im writing an application which in some part of this application i need to generate some code in application's run time and create an exe file and run that .exe get some result from that, then cleanup every thing!

    but my problem is i dont know how to add-in some reference
    for example if i have something like this, when i compile generated codes i give compile error which indicate that i did not add references!!!!

    Code:
    // Some generated code here ...
    
    // COMPILE ERROR : I DID NOT ADD ' SYSTEM.XML ' REFERENCE
    System.Xml.XmlConvert obj = new System.Xml.XmlConvert();
    
    // Some other generated code here ...
    can someone give me some useful and correct code/reference ???

    i need help ASAP

    thanks in advance

  2. #2
    Join Date
    Oct 2005
    Location
    Seattle, WA U.S.A.
    Posts
    353

    Re: Add-in reference programmatically

    You don't give us a lot to work with here but I tried it on my machine and found that either a 'using' statement ( using System.Xml; ), OR the fully qualified name (such as you provide with your "System.Xml." prepends) is required .....

    In short, it works on my machine. Can you show us the statement BEFORE the statement that fails ? that could be at fault causing the compile error to appear at the following statement.


    Another possibility is that the reference is missing from the solution although I think it appears by default. Still, it'd be worthwhile to check ......

    1. If it isn't already on your screen, bring up the Solution Explorer
    2. Click on the plus sign adjacent to the 'references' folder - probably just above the list of source files in your Solution Explorer
    3. Look for "System.Xml" in the list of references. If it's absent then you'll probably need to add it ....
    3.a. RIGHT-click on the "references" folder and click on "Add Reference"
    3.b. After a brief period, a list of references will appear. Look for "System.Xml" in that list and double click on it.

    Good Luck.

    OldFool
    Last edited by ThermoSight; March 7th, 2011 at 12:28 AM.

  3. #3
    Join Date
    Mar 2011
    Posts
    23

    Re: Add-in reference programmatically

    Quote Originally Posted by ThermoSight View Post
    1. If it isn't already on your screen, bring up the Solution Explorer
    2. Click on the plus sign adjacent to the 'references' folder - probably just above the list of source files in your Solution Explorer
    3. Look for "System.Xml" in the list of references. If it's absent then you'll probably need to add it ....
    3.a. RIGHT-click on the "references" folder and click on "Add Reference"
    3.b. After a brief period, a list of references will appear. Look for "System.Xml" in that list and double click on it.
    I think Dariush wants to do that programmatically. I think the code is generated by an executing program.

  4. #4
    Join Date
    Oct 2005
    Location
    Seattle, WA U.S.A.
    Posts
    353

    Re: Add-in reference programmatically

    Programmatically ?

    Now I understand his thread title. I shouldn't have been so quick to dismiss it .... Good Luck ! I would think that requires knowledge of VS internals. Way outta my league.

    Could it be a Visual Studio options/default setting? I note that on my machine, System.Xml is present in the references list even though the project has nothing to do with Xml.

    Old Fool

  5. #5
    Join Date
    Mar 2011
    Posts
    23

    Re: Add-in reference programmatically

    Quote Originally Posted by ThermoSight View Post
    Programmatically ?

    Now I understand his thread title. I shouldn't have been so quick to dismiss it .... Good Luck ! I would think that requires knowledge of VS internals. Way outta my league.

    Could it be a Visual Studio options/default setting? I note that on my machine, System.Xml is present in the references list even though the project has nothing to do with Xml.

    Old Fool
    Hahaha. One has to go back to pre-IDE days. The problem reduces to programmatically constructing command lines for the compiler and linker. Given all the DLLS, its the Linker's job to find all the unresolved symbols.
    Might be easier if the DLLS were made into one large library file. I don't know how to do that, but no IDE is required.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Add-in reference programmatically

    @OP. Why would you want to dynamically create an exe program on the fly and run it? Why not just execute the code within the first exe?

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

Featured