-
March 6th, 2011, 03:29 PM
#1
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
-
March 7th, 2011, 12:24 AM
#2
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.
-
March 7th, 2011, 01:11 AM
#3
Re: Add-in reference programmatically
Originally Posted by ThermoSight
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.
-
March 7th, 2011, 12:59 PM
#4
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
-
March 8th, 2011, 09:58 AM
#5
Re: Add-in reference programmatically
Originally Posted by ThermoSight
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.
-
March 8th, 2011, 11:31 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|