i´ve got a project, which referencces to a nother project, a core. in a 3rd project, i´m resolving the assemblys. I easily can get the first project, but it gives me an error because of the core, it cant find it. do you know what to add?
public MainWindow()
{
InitializeComponent();
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var assembly = Assembly.Load(@"C:\Users\source\Project1\...\MainProgramm.exe");
var windowType = assembly.DefinedTypes.FirstOrDefault(t => t != typeof(Window) && typeof(Window).IsAssignableFrom(t));
var window = (Window)Activator.CreateInstance(windowType);
window.Background = Brushes.Green;
var tmp = window.ShowDialog();
}
static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
AssemblyName an = AssemblyName.GetAssemblyName(args.Name);
using(var memoryStream = new MemoryStream())
using(var fileStream = new FileStream(args.Name, FileMode.Open))
{
byte[] bytes = new byte[fileStream.Length];
fileStream.Read(bytes, 0, (int)fileStream.Length);
memoryStream.Write(bytes, 0, (int)fileStream.Length);
return Assembly.Load(bytes);
}
}
the "CoreProject" it in the folderpath: @"C:\Users\source\Project1\Project1Core\"
Aucun commentaire:
Enregistrer un commentaire