This code (adapted from the examples in the docs) doesn't make complete
sense to me. I have it working, but I'm wondering why I need to declare an
assembly reference in 2 places. TIA.
Dave
CodeCompileUnit compileUnit = new CodeCompileUnit();
CodeNamespace myNamespace = new CodeNamespace("MyNamespace");
compileUnit.Namespaces.Add( myNamespace );
compileUnit.ReferencedAssemblies.Add(@"MyDLL.dll") ;//I declare an assembly
reference here first
myNamespace.Imports.Add( new CodeNamespaceImport("System") );
myNamespace.Imports.Add( new CodeNamespaceImport("MyOtherNamespace") );
[...]
ICodeCompiler compiler = provider.CreateCompiler();
CompilerParameters cp = new CompilerParameters(
new string[] {"System.dll",
"MyDLL.dll" //Now I still have to declare the assembly reference here too.
Why?
},
filepath.Substring(0, filepath.LastIndexOf(".") + 1)+"dll", false); 3 2046
I think this is similar to VS.NET IDE does internally
You must be knowing that
1) You can add references to assemblies that you wish to use by "Add
Reference"
2) You can use any of the classes of "References" inside your classes
using "using" statement
So, while compiling, you need to provide, which DLLs you want to add to
current assembly in compilation.
Since, there is a possibility that
Although you have added a ref. to an external assembly, but you dont
want to it to be included as a part of your assembly
Correct me, anyone, if I am conceptually wrong
Kalpesh
Mountain Bikn' Guy wrote: This code (adapted from the examples in the docs) doesn't make complete sense to me. I have it working, but I'm wondering why I need to declare an assembly reference in 2 places. TIA. Dave
CodeCompileUnit compileUnit = new CodeCompileUnit(); CodeNamespace myNamespace = new CodeNamespace("MyNamespace"); compileUnit.Namespaces.Add( myNamespace ); compileUnit.ReferencedAssemblies.Add(@"MyDLL.dll") ;//I declare an assembly reference here first
myNamespace.Imports.Add( new CodeNamespaceImport("System") ); myNamespace.Imports.Add( new CodeNamespaceImport("MyOtherNamespace") );
[...]
ICodeCompiler compiler = provider.CreateCompiler(); CompilerParameters cp = new CompilerParameters( new string[] {"System.dll",
"MyDLL.dll" //Now I still have to declare the assembly reference here too. Why?
},
filepath.Substring(0, filepath.LastIndexOf(".") + 1)+"dll", false);
The "using" statements are taken care of by CodeNamespaceImport. However,
I'm speaking specifically about the need to declare assembly references
twice. I make one call with ReferencedAssemblies.Add. Then I am still
required (or I get errors) to define the assembly reference again as a
CompilerParameters parameter. That is the part that doesn't make sense to
me. It seems that ReferencedAssemblies.Add is not fully taking care of of
the task of defining a referenced assembly.
Dave
"Kalpesh" <sh*********@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... I think this is similar to VS.NET IDE does internally
You must be knowing that 1) You can add references to assemblies that you wish to use by "Add Reference" 2) You can use any of the classes of "References" inside your classes using "using" statement
So, while compiling, you need to provide, which DLLs you want to add to current assembly in compilation.
Since, there is a possibility that Although you have added a ref. to an external assembly, but you dont want to it to be included as a part of your assembly
Correct me, anyone, if I am conceptually wrong
Kalpesh
Mountain Bikn' Guy wrote:
This code (adapted from the examples in the docs) doesn't make complete sense to me. I have it working, but I'm wondering why I need to declare
an assembly reference in 2 places. TIA. Dave
CodeCompileUnit compileUnit = new CodeCompileUnit(); CodeNamespace myNamespace = new CodeNamespace("MyNamespace"); compileUnit.Namespaces.Add( myNamespace ); compileUnit.ReferencedAssemblies.Add(@"MyDLL.dll") ;//I declare an
assembly reference here first
myNamespace.Imports.Add( new CodeNamespaceImport("System") ); myNamespace.Imports.Add( new CodeNamespaceImport("MyOtherNamespace") );
[...]
ICodeCompiler compiler = provider.CreateCompiler(); CompilerParameters cp = new CompilerParameters( new string[] {"System.dll",
"MyDLL.dll" //Now I still have to declare the assembly reference here
too. Why?
},
filepath.Substring(0, filepath.LastIndexOf(".") + 1)+"dll", false);
"Mountain Bikn' Guy" <vc@attbi.com> wrote in message
news:gsdlb.845178$uu5.150092@sccrnsc04... This code (adapted from the examples in the docs) doesn't make complete sense to me. I have it working, but I'm wondering why I need to declare an assembly reference in 2 places.
CodeCompileUnit compileUnit = new CodeCompileUnit();
Hi. I'm wondering why you are working with CodeCompileUnit at all? Do you
have source code you are trying to compile or what?
If you have source code to work with then you would create the Compiler
object, add your CompilerParameters object, add your ReferencedAssemblies
and call CompileAssemblyFromSource() to compiler. In this situation there
is only one time you need to add references.
-- Alan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mountain Bikn' Guy |
last post by:
This code (adapted from the examples in the docs) doesn't make complete
sense to me. I have it working, but I'm wondering why I need to declare an
assembly reference in 2 places. TIA.
Dave
...
|
by: James Thurley |
last post by:
I'm trying to dynamically compile assemblies and cache them to disk,
which seems to work fine. When the data I'm compiling from changes, I
want to re-generate the assembly and use the new version....
|
by: Vladimir Semenov |
last post by:
Hi,
I'm trying to serialize a type contained in assembly referering to another assembly in GAC.
XmlSerializer xs = new XmlSerializer( typeof(TransferParentData ) );
The code above throws...
|
by: Cornu Nicolas |
last post by:
Hello,
The above code generate the above error.
The not found assembly is different at each execution.
--------------------------------------------------------------------------
public void...
|
by: Martinh |
last post by:
Hi
After invoking RetrieveData in a WebService I recieve the following
response in a new window...
I am running Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573 ...
|
by: jcvoon |
last post by:
Hi:
My application will compile a source code and generate an executable
assembly during run time, i'm able to generate the exe, but i don't
know the correct way to link a resource file into...
|
by: Richard Gregory |
last post by:
Hi,
I have the wsdl below, for an Axis web service, and when I select Add Web
Refernce in Visual Studio the proxy is missing a class representing the
returnedElementsType (see reference.cs below...
|
by: Luis Arvayo |
last post by:
I am compiling and executing c# code at runtime and I need to define in
CompilerParameters.ReferencedAssemblies one of my own assemblies together
with the standard System.dll u others.
Example:...
|
by: Andrus |
last post by:
I need compile in-memory assembly which references to other in-memory
assembly.
Compiling second assembly fails with error
Line: 0 - Metadata file 'eed7li9m, Version=0.0.0.0, Culture=neutral,...
|
by: Montezuma's Daughter |
last post by:
Hi all
it is my first application. I wrote a class libraray with functions
and a simple class with form, textbox, buttons and a label.
I added reference to the second class so I would read the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |