-
[C#] C# dll COM, CommonUIC#/기초 2025. 1. 21. 12:00
Visual Studio 2022
COM 생성 (ex. C# WPF CommonUI)
프로젝트 생성
.Net Framework
C#
Properties
Output type: Class Library
Assembly Information..
COM등록
Register.bat0.00MBUnRegister.bat0.00MBCOM호출
WPF App (.Net 6 )
MFC
https://blog.naver.com/dks444/220427871338
dll load
3rd Party Component ex) DevExpress
.exe 실행파일 경로에 COM 이 필요로하는 dll 넣어줘야 로드 함. (WPF, MFC 동일)
ex)
DevExpress 는 관련 dll 들 Deployment Tool이용. (Ctrl + C ,V 로 dll 복사시 구동에 빠져있는 dll들이 있음. ex) Themes.~.dll )
COM.dll 은 빼고 COM.dll이 호출하는 나머지(DevExpress.dll)들만 복사
# COM.dll (EngSearch.CommonLib.dll) 복사 시 등록된 COM을 제대로 호출 못하는 상황 있음.
# Com.dll 위치에서 assemblyload
public SearchCom() { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += new ResolveEventHandler(currentDomain_AssemblyResolve); }
Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string applicationDirectory = Path.GetDirectoryName(executingAssembly.Location); string[] fields = args.Name.Split(','); string assemblyName = fields[0]; string assemblyCulture; if (fields.Length < 2) assemblyCulture = null; else assemblyCulture = fields[2].Substring(fields[2].IndexOf('=') + 1); //MessageBox.Show($"Assembly Name: {assemblyName}, Culture: {assemblyCulture}", "Assembly Resolve"); string assemblyFileName = assemblyName + ".dll"; string assemblyPath; if (assemblyName.EndsWith(".resources")) { // Specific resources are located in app subdirectories string resourceDirectory = Path.Combine(applicationDirectory, assemblyCulture); assemblyPath = Path.Combine(resourceDirectory, assemblyFileName); } else { assemblyPath = Path.Combine(applicationDirectory, assemblyFileName); } if (File.Exists(assemblyPath)) { //Load the assembly from the specified path. Assembly loadingAssembly = Assembly.LoadFrom(assemblyPath); //Return the loaded assembly. return loadingAssembly; } else { return null; } }
CommonUI
Icon, Theme
#Com interop에서 CallbackCallback 인터페이스
callback 객체를 담을 그릇
담을 객체 틀
Callback객체를 만들어서 전달
전달 받은 callback 객체 사용.
https://petra.tistory.com/1130
C# COM 만들기
C# COM 만들기 윈도우10, VisualStudio2017 기준 MFC Client : http://petra.tistory.com/1133 1. Visual Stidio 2017을 관리자 모드로 실행한다. 2. 아래 그림처럼 클래스 라이브러리(.NET Framework) _COMTest 프로젝트를 만든다.
petra.tistory.com
https://blog.naver.com/techshare/220976095805
C# 개발자를 위한 C++ COM 객체의 기본 구현 방식 설명
순수 C# 개발자들이라면, 아마도 C++ COM 객체는 잘 이해가 안 되는 개념일 수 있습니다. 물론, C++...
blog.naver.com
728x90'C# > 기초' 카테고리의 다른 글
[C#] 정규식, Regex (0) 2025.02.18 [C#][별**] object to List<> (0) 2025.02.12 [C#] gRPC Exception (0) 2025.01.14 [C#] List 중복 제거 (0) 2024.12.18 [C#] !. 연산자 (0) 2024.12.04 댓글