Hej, mam problem z CSharpCodeProvider.
Chodzi mi o to, że jak wczytuje kod z innego pliku to wyświetla mi, że nie ma takiej funkcji, a chce żeby ta funkcja była pobierania z głównego programu.
Kod z tego drugiego pliku:
using System;
public class SkEditorAddon
{
public void Main()
{
CreateSeparator();
CreateButton("Fajny", Properties.Resources.book_stack_16, click);
}
}
Funkcje z głównego programu:
public void CreateSeparator()
{
ToolStripSeparator separator = new ToolStripSeparator();
toolStrip1.Items.Add(separator);
}
public void CreateButton(string Name, System.Drawing.Image ButtonIcon, System.EventHandler ButtonFunction)
{
ToolStripButton button = new ToolStripButton();
button.Text = Name;
button.Image = ButtonIcon;
button.Click += ButtonFunction;
button.DisplayStyle = ToolStripItemDisplayStyle.Image;
toolStrip1.Items.Add(button);
}
oraz wczytywanie kodu z innego pliku
Directory.CreateDirectory("Addons");
string[] filesA = Directory.GetFiles("Addons");
foreach (string addons in filesA) Debug.WriteLine("ADDONS: " + addons);
CompilerParameters cp = new CompilerParameters();
cp.GenerateExecutable = true;
cp.GenerateInMemory = false;
cp.TreatWarningsAsErrors = false;
CSharpCodeProvider provider = new CSharpCodeProvider();
foreach (string addons in filesA)
{
CompilerResults cResults = provider.CompileAssemblyFromFile(cp, addons);
if (cResults.Errors.HasErrors)
{
foreach (CompilerError ce in cResults.Errors)
Debug.WriteLine("Errors building :" + ce.ToString());
}
else if (cResults.Errors.HasWarnings)
{
foreach (CompilerError ce in cResults.Errors)
Debug.WriteLine("Warning building :" + ce.ToString());
}
else
{
System.Type type = cResults.CompiledAssembly.GetType("SkEditorAddon");
}
}
Proszę o pomoc