Click here to Skip to main content
15,887,449 members
Home / Discussions / C#
   

C#

 
GeneralRe: c# adding events to programmaticlly added controls Pin
Nagy Vilmos22-Jul-09 2:03
professionalNagy Vilmos22-Jul-09 2:03 
QuestionHow to login a user to a website using HttpWebRequest and HttpWebResponse Pin
sumit703422-Jul-09 0:45
sumit703422-Jul-09 0:45 
AnswerRe: How to login a user to a website using HttpWebRequest and HttpWebResponse Pin
Member 103390722-Jul-09 1:24
Member 103390722-Jul-09 1:24 
GeneralRe: How to login a user to a website using HttpWebRequest and HttpWebResponse Pin
sumit703422-Jul-09 1:28
sumit703422-Jul-09 1:28 
QuestionRe Sizing List View Column Pin
satsumatable22-Jul-09 0:38
satsumatable22-Jul-09 0:38 
AnswerRe: Re Sizing List View Column Pin
DaveyM6922-Jul-09 0:55
professionalDaveyM6922-Jul-09 0:55 
AnswerRe: Re Sizing List View Column Pin
Mycroft Holmes22-Jul-09 1:00
professionalMycroft Holmes22-Jul-09 1:00 
QuestionSome questions about using the C# code compiler ( CSharpCodeProvider ) [modified] Pin
MafiaMoe22-Jul-09 0:38
MafiaMoe22-Jul-09 0:38 
Have some issues and questions about creating a .dll from code in the form of a string array and a file. I seem to be close, but errors are raised when the code tries to creat the .dll.

Main question is, does the 'OutputAssembly' refer to the file name to create? Whenever I run the code below it says it could not find the file that 'cp.OutputAssembly' is set to. Also if this line is commented out, it says it could not find a randomly named file in a temporary directory.

The other question I have is if there is any difference between creating the .dll from an existing file or a string array. I plan on having the system create a common .dll for both the main program and for other .dll's the main program creates. These non-common .dll's can then be used directly in other programs.

This code is to create the common .dll .

public CompilerResults CompileImageAquisition(string OutputFile)
        {
            CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");

            CompilerParameters cp = new CompilerParameters();

            CodeTypeReferenceCollection cref = new CodeTypeReferenceCollection();

            cp.OutputAssembly = OutputFile;
            cp.GenerateInMemory = false;
            cp.TreatWarningsAsErrors = false;
            cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\PresentationCore.dll");
            cp.ReferencedAssemblies.Add("System.Drawing.dll");
            cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.Windows.Forms.dll");
            cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.XML.dll");

            CompilerResults cr = provider.CompileAssemblyFromFile(cp, ImageCoderSourceLocation);

            if (cr.Errors.Count > 0)
            {
                // Display compilation errors.
                Console.WriteLine("Errors building {0} into {1}", ImageCoderSourceLocation, cr.PathToAssembly);
                foreach (CompilerError ce in cr.Errors)
                {
                    Console.WriteLine("  {0}", ce.ToString());
                    Console.WriteLine();
                }
            }
            else
            {
                // Display a successful compilation message.
                Console.WriteLine("Source {0} built into {1} successfully.", ImageCoderSourceLocation, cr.PathToAssembly);
            }

            return cr;
        }


modified on Wednesday, July 22, 2009 6:51 AM

AnswerRe: Some questions about using the C# code compiler ( CSharpCodeProvider ) Pin
MafiaMoe22-Jul-09 11:44
MafiaMoe22-Jul-09 11:44 
QuestionStream Reader Problem Pin
Paul Unsworth22-Jul-09 0:09
Paul Unsworth22-Jul-09 0:09 
AnswerRe: Stream Reader Problem Pin
OriginalGriff22-Jul-09 0:26
mveOriginalGriff22-Jul-09 0:26 
GeneralRe: Stream Reader Problem Pin
Paul Unsworth22-Jul-09 0:43
Paul Unsworth22-Jul-09 0:43 
GeneralRe: Stream Reader Problem Pin
OriginalGriff22-Jul-09 1:04
mveOriginalGriff22-Jul-09 1:04 
GeneralRe: Stream Reader Problem Pin
Paul Unsworth22-Jul-09 1:20
Paul Unsworth22-Jul-09 1:20 
GeneralRe: Stream Reader Problem Pin
OriginalGriff22-Jul-09 1:23
mveOriginalGriff22-Jul-09 1:23 
GeneralRe: Stream Reader Problem Pin
Paul Unsworth22-Jul-09 1:38
Paul Unsworth22-Jul-09 1:38 
GeneralRe: Stream Reader Problem Pin
OriginalGriff22-Jul-09 1:42
mveOriginalGriff22-Jul-09 1:42 
AnswerRe: Stream Reader Problem Pin
MarkB77722-Jul-09 0:31
MarkB77722-Jul-09 0:31 
GeneralRe: Stream Reader Problem Pin
Paul Unsworth22-Jul-09 0:42
Paul Unsworth22-Jul-09 0:42 
GeneralRe: Stream Reader Problem Pin
MarkB77722-Jul-09 0:43
MarkB77722-Jul-09 0:43 
GeneralRe: Stream Reader Problem Pin
Paul Unsworth22-Jul-09 1:07
Paul Unsworth22-Jul-09 1:07 
GeneralRe: Stream Reader Problem Pin
MarkB77722-Jul-09 1:21
MarkB77722-Jul-09 1:21 
AnswerRe: Stream Reader Problem Pin
Luc Pattyn22-Jul-09 1:23
sitebuilderLuc Pattyn22-Jul-09 1:23 
Questionwriting javascript in code behind [modified] Pin
kKamel21-Jul-09 23:48
kKamel21-Jul-09 23:48 
AnswerRe: writing javascript in code behind Pin
Brij22-Jul-09 0:02
mentorBrij22-Jul-09 0:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.