Im currently making a app that needs to download some raw data from the internet, the problem is that the app is compiled by another c# app (builder), so im using the CSharpCodeProvider which generates .NET 4 assemblies.
The problem now is that when using WebClient or HttpClient in .NET 4 it says
Could not create SSL/TLS secure channel
Is there a method to download stuff like that in .NET 4?
Download function:
static async Task<byte[]> GetData()
{
HttpResponseMessage response =
await new HttpClient().GetAsync(Url);
return await response.Content.ReadAsByteArrayAsync();
}
Compiler:
var providerOptions = new Dictionary<string, string> { { "CompilerVersion", "v4.0" } };
using (var provider = new CSharpCodeProvider(providerOptions))
{
var compilerParameters = new CompilerParameters
{
GenerateExecutable = true,
OutputAssembly = outputExe
};
if (iconFile != null)
compilerParameters.CompilerOptions = $@"/win32icon:""{iconFile}""";
if (references != null && references.Length > 0)
compilerParameters.ReferencedAssemblies.AddRange(references);
CompilerResults results = provider.CompileAssemblyFromSource(compilerParameters, sourceCode);
if (results.Errors.HasErrors)
{
string errors = string.Join(Environment.NewLine, results.Errors.Cast<CompilerError>().Select(e => e.ErrorText));
MessageBox.Show($"Compilation failed:{Environment.NewLine}{errors}", "WT Error");
}
}
I tried to get raw data from internet but I got a error.