Код: Выделить всё
.designer.csОднако, когда я пытаюсь извлечь тип из сборки, появляется следующая ошибка: < /p>
не может загрузить тип 'System.object' from Assembly 'System.private.corelib', потому что родитель не существует. Посмотрел повсюду, но я не смог найти исправление для этой ошибки в случае, подобном моим. Это первый раз, когда я делаю расширение Visual Studio и использую подобные сборки, поэтому я был бы очень благодарен, если бы кто -то мог мне помочь, заранее! Formcombobox_selectionChanged событие, которое выглядит следующим образом:
Код: Выделить всё
private void FormsComboBox_SelectionChanged(object sender, RoutedEventArgs e)
{
string file = "";
try
{
// Reflection approach - loads all the requested assemblies
AppDomain.CurrentDomain.AssemblyResolve += Resolver;
// Dynamically load project's assembly
Assembly assembly = Assembly.LoadFrom(Path.Combine(Path.GetDirectoryName(clientProject.FullName), "bin\\Debug\\net8.0-windows\\" + clientProject.Properties.Item("OutputFilename").Value.ToString()));
// Get the assembly name (with namespaces)
file = files.Where(s => s.Contains(FormsComboBox.SelectedItem.ToString())).First();
// Get the Type from the assembly (HERE IS WHERE THE ERROR POPS UP)
Type formType = assembly.GetType(GetAssemblyName(file), true, true);
// Create an object of the Type
object formClass = Activator.CreateInstance(formType);
// Fill the ListView with the project's Form Class Controls
controls.Clear();
if (formClass is System.Windows.Forms.Form form)
{
foreach (System.Windows.Forms.Control control in form.Controls)
{
controls.Add(control);
}
}
ControlListView.Items.Clear();
for (int i = 0; i < controls.Count; i++)
{
ControlListView.Items.Add("(" + controls[i].GetType().Name + ") " + controls[i].Name);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + ex.StackTrace);
}
}
Вы также можете просто добавить комментарий, и я постараюсь ответить, как только смогу.>
Подробнее здесь: https://stackoverflow.com/questions/795 ... relib-beca
Мобильная версия