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.Nam espaces.Add( myNamespace );
compileUnit.Ref erencedAssembli es.Add(@"MyDLL. dll");//I declare an assembly
reference here first
myNamespace.Imp orts.Add( new CodeNamespaceIm port("System") );
myNamespace.Imp orts.Add( new CodeNamespaceIm port("MyOtherNa mespace") );
[...]
ICodeCompiler compiler = provider.Create Compiler();
CompilerParamet ers cp = new CompilerParamet ers(
new string[] {"System.dll ",
"MyDLL.dll" //Now I still have to declare the assembly reference here too.
Why?
},
filepath.Substr ing(0, filepath.LastIn dexOf(".") + 1)+"dll", false); 3 9400
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.Nam espaces.Add( myNamespace ); compileUnit.Ref erencedAssembli es.Add(@"MyDLL. dll");//I declare an assembly reference here first
myNamespace.Imp orts.Add( new CodeNamespaceIm port("System") ); myNamespace.Imp orts.Add( new CodeNamespaceIm port("MyOtherNa mespace") );
[...]
ICodeCompiler compiler = provider.Create Compiler(); CompilerParamet ers cp = new CompilerParamet ers( new string[] {"System.dll ",
"MyDLL.dll" //Now I still have to declare the assembly reference here too. Why?
},
filepath.Substr ing(0, filepath.LastIn dexOf(".") + 1)+"dll", false);
The "using" statements are taken care of by CodeNamespaceIm port. However,
I'm speaking specifically about the need to declare assembly references
twice. I make one call with ReferencedAssem blies.Add. Then I am still
required (or I get errors) to define the assembly reference again as a
CompilerParamet ers parameter. That is the part that doesn't make sense to
me. It seems that ReferencedAssem blies.Add is not fully taking care of of
the task of defining a referenced assembly.
Dave
"Kalpesh" <sh*********@ya hoo.com> wrote in message
news:%2******** ********@tk2msf tngp13.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.Nam espaces.Add( myNamespace ); compileUnit.Ref erencedAssembli es.Add(@"MyDLL. dll");//I declare an
assembly reference here first
myNamespace.Imp orts.Add( new CodeNamespaceIm port("System") ); myNamespace.Imp orts.Add( new CodeNamespaceIm port("MyOtherNa mespace") );
[...]
ICodeCompiler compiler = provider.Create Compiler(); CompilerParamet ers cp = new CompilerParamet ers( new string[] {"System.dll ",
"MyDLL.dll" //Now I still have to declare the assembly reference here
too. Why?
},
filepath.Substr ing(0, filepath.LastIn dexOf(".") + 1)+"dll", false);
"Mountain Bikn' Guy" <vc@attbi.com > wrote in message
news:gsdlb.8451 78$uu5.150092@s ccrnsc04... 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 CompilerParamet ers object, add your ReferencedAssem blies
and call CompileAssembly FromSource() 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: 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 exception:
System.IO.FileNotFoundException : File or assembly name rng0i4ly.dll, or one of its dependencies, was not found.
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity,...
|
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
CodeCompileUnit compileUnit = new CodeCompileUnit();
CodeNamespace myNamespace = new CodeNamespace("MyNamespace");
compileUnit.Namespaces.Add( myNamespace );
compileUnit.ReferencedAssemblies.Add(@"MyDLL.dll");//I declare an assembly
reference here...
|
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 WritePatchConfiguration(StreamWriter wr)
{
System.Xml.Serialization.XmlSerializer writer = new
XmlSerializer(this.GetType());
|
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 on IIS6 on Server 2003 Enterprise. Does anybody
has a working solution for me?
Martin
|
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 exe.
here is my code to generate the exe during run time:
Public Sub GenerateStub()
Dim sSourceCode As String = Path.Combine(Path.GetTempPath,
| |
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 the wsdl). This complex type is
a collection of another complex type(elementType), and the Reference.cs has
an array of these rather than the single returnedElementsType. If If I want
to be able to obtain these elements from the SOAP response I...
|
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:
// compiler options
System.CodeDom.Compiler.CompilerParameters options = new
System.CodeDom.Compiler.CompilerParameters();
options.GenerateExecutable = false; // result is a dll
|
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,
PublicKeyToken=null' could not be found
Saving assembly to Windows temp directory for referencing only creates huge
amout of temporary
|
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 class
library. the I met 2 problems:
1.test data in the textbox is string and I need a double, how do I
convert it?
2.in default.cs I get en error message :
======================================================
One or more errors encountered...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |