디자이너 디자이너 커스텀 모듈 추가 관련 소스가 궁금합니다.
페이지 정보
본문
예제 부탁드립니다!
- 이전글관리자 권한 상태를 알 수 있나요? 20.06.08
- 다음글디자이너 form갱신 관련.. 20.06.07
댓글목록
엔지엠소프트웨어님의 댓글
엔지엠소프트웨어 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 작성일 Date
Program.cs에 아래와 같이 이벤트를 하나 만듭니다.
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolveAssembly);
그리고, 이벤트 핸들러는 아래와 같이 코딩하시면 됩니다.
static Assembly ResolveAssembly(object sender, ResolveEventArgs args)
{
Assembly thisAssembly = Assembly.GetExecutingAssembly();
string fileName = args.Name.Substring(0, args.Name.IndexOf(',')) + ".dll";
if (fileName.ToUpper().StartsWith("CUSTOM"))
{
string existModlueFullPath = Path.Combine(NGM.Models.Configuration.SystemConfigModel.CustomToolExtensionDirectory, fileName);
if (!File.Exists(existModlueFullPath))
{
existModlueFullPath = Path.Combine(NGM.Models.Configuration.SystemConfigModel.CustomFunctionExtensionDirectory, fileName);
if (!File.Exists(existModlueFullPath))
{
return null;
}
}
byte[] file = File.ReadAllBytes(existModlueFullPath);
return Assembly.Load(file);
}
string resourceName = null;
if (thisAssembly.ImageRuntimeVersion.Contains("v4"))
{
var resources = thisAssembly.GetManifestResourceNames().Where(s => s.EndsWith(fileName));
if (resources.Count() > 0)
{
resourceName = resources.First();
using (Stream stream = thisAssembly.GetManifestResourceStream(resourceName))
{
if (stream != null)
{
byte[] assembly = new byte[stream.Length];
stream.Read(assembly, 0, assembly.Length);
return Assembly.Load(assembly);
}
}
}
}
else
{
foreach (string name in thisAssembly.GetManifestResourceNames())
{
if (name.EndsWith(fileName))
{
resourceName = name;
break;
}
}
if (resourceName != null)
{
using (Stream stream = thisAssembly.GetManifestResourceStream(resourceName))
{
if (stream != null)
{
byte[] assembly = new byte[stream.Length];
stream.Read(assembly, 0, assembly.Length);
return Assembly.Load(assembly);
}
}
}
}
return null;
}