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

C#

 
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 
AnswerRe: Some questions about using the C# code compiler ( CSharpCodeProvider ) Pin
MafiaMoe22-Jul-09 11:44
MafiaMoe22-Jul-09 11:44 
Replying to my own post. After some extra debugging I was able to get the compile sequence to create a .dll. Here is and updated code to show what was changed and give a working example for anyone else to use as an example.

'OutputFile' has the directory of the file you wish to create such as "C:\\Folder\\File.dll". You can also set 'cp.GenerateExecutable = True' to have it create a .exe file.

'cref' is the directory to a C# file, such as "C:\\Folder\\Code.cs", but can also be a .txt.

You should be able to modify the code so the 'ReferencedAssemblies.Add' lines look more like "cp.ReferencedAssemblies.Add("System.dll");", but I was having some issues with it not being able to compile without the full path. This could just be a bug in VS2010 beta.

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\\System.dll");
    cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\PresentationCore.dll");
    cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\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;
}

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 
GeneralRe: writing javascript in code behind Pin
kKamel22-Jul-09 0:28
kKamel22-Jul-09 0:28 

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.