На C# такой код public partial class Form1 : Form { public Form1() {…
- User
На C# такой код
public partial class Form1 : Form { public Form1() { InitializeComponent(); AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly; CreateLanguageFolders(); MoveDirectoriesWithContent(); } private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args) { System.Diagnostics.Debug.WriteLine($"Trying to resolve assembly: { args.Name}"); string assemblyFileName = new AssemblyName(args.Name).Name + ".dll"; // Имя файла сборки string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; // Сначала проверяем корневой каталог string assemblyPath = Path.Combine(baseDirectory, assemblyFileName); if (File.Exists(assemblyPath)) { return Assembly.LoadFrom(assemblyPath); } // Затем проверяем поддиректории в директории ‘MyDllFolder’ string[] subfolders = { "ru", "de", "it", "ja", "es", "fr", "hu", "pt", "sk", "sv", "tr", "zh-cn", "zh-tw", "x86", "x64" }; string customAssemblyPath = Path.Combine(baseDirectory, "MyDllFolder"); foreach (string subfolder in subfolders) { assemblyPath = Path.Combine(customAssemblyPath, subfolder, assemblyFileName); if (File.Exists(assemblyPath)) { return Assembly.LoadFrom(assemblyPath); } } // Если файл не найден ни в корневом каталоге ни в подпапках MyDllFolder return null; } private void CreateLanguageFolders() { string rootFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MyDllFolder"); // Создаем корневую папку, если она еще не существует if (!Directory.Exists(rootFolder)) { Directory.CreateDirectory(rootFolder); } } private void MoveDirectoriesWithContent() { string sourcePath = AppDomain.CurrentDomain.BaseDirectory; // Путь к корневой папке string destinationPath = Path.Combine(sourcePath, "MyDllFolder"); string[] languageFolders = { "ru", "de", "it", "ja", "es", "fr", "hu","pt","sk","sv","tr","zh-cn","zh-tw","x86","x64" }; foreach (string folder in languageFolders) { string sourceFolder = Path.Combine(sourcePath, folder); string destinationFolder = Path.Combine(destinationPath, folder); // Перемещаем папку и её содержимое, если она существует if (Directory.Exists(sourceFolder)) { // Если целевая папка уже существует, сначала её нужно удалить if (Directory.Exists(destinationFolder)) { Directory.Delete(destinationFolder, true); // true позволяет удалять рекурсивно } Directory.Move(sourceFolder, destinationFolder); } } // Перемещение конкретных файлов string[] filesToMove = { "Emgu.CV.UI.dll", "Emgu.CV.UI.xml", "Emgu.CV.World.dll", "Emgu.CV.World.xml", "ZedGraph.dll", "ZedGraph.xml" }; foreach (string fileName in filesToMove) { string sourceFile = Path.Combine(sourcePath, fileName); string destinationFile = Path.Combine(destinationPath, fileName); if (File.Exists(sourceFile)) { if (File.Exists(destinationFile)) { File.Delete(destinationFile); // Удалить существующий файл, если он есть } File.Move(sourceFile, destinationFile); // Перемещаем файл } } } private void CopyDirectory(string sourceDir, string destinationDir) { DirectoryInfo dir = new DirectoryInfo(sourceDir); if (!dir.Exists) { throw new DirectoryNotFoundException($"Source directory not found: { sourceDir }"); } DirectoryInfo[] dirs = dir.GetDirectories(); if (!Directory.Exists(destinationDir)) { Directory.CreateDirectory(destinationDir); } FileInfo[] files = dir.GetFiles(); foreach (FileInfo file in files) { string tempPath = Path.Combine(destinationDir, file.Name); file.CopyTo(tempPath, false); // overwrite параметр намеренно установлен в false, чтобы предотвратить перезапись } foreach (DirectoryInfo subdir in dirs) { string tempPath = Path.Combine(destinationDir, subdir.Name); CopyDirectory(subdir.FullName, tempPath); } } private void button1_Click(object sender, EventArgs e) { // Вынесем обработку скриншота и изображения в отдельный метод string imagePath = ImageProcessor.CaptureAndProcessImage(); // Выполнение кода из GetPrice.cs string extractedText = GetPrice.ProcessImage(imagePath); // Перенос номера в label1 или textBox1 label1.Text = extractedText; } } - Assistant
Сообщение об ошибке, которое вы видите, указывает на то, что приложение не может найти и загрузить сборку
Emgu.CV.Worldс указанной версией4.1.1.3497. Это может происходить по разным причинам, но наиболее вероятные это:- Сборка
Emgu.CV.World.dllотсутствует в ожидаемом каталоге при выполнении приложения.
- Сборка
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.