2 개의 C# 프로젝트가 서로 참조해야하는 경우가 있습니다. 따라서 어셈블리 A는 어셈블리 B를 참조합니다. 어셈블리 B는 리플렉션을 사용하여 A를로드합니다. 명령 행 응용 프로그램에서 훌륭하게 작동합니다. 실행중인 어셈블리를로드 할 수 없습니다.
그러나 내 말 COM 추가 기능에서 나는 다음과 같은 오류가 점점 오전
:Could not load file or assembly 'WindwardReports, Version=15.0.142.0, Culture=neutral,
PublicKeyToken=34ffe15f4bbb8e53' or one of its dependencies.
The system cannot find the file specified.
FusionLog
=== Pre-bind state information ===
LOG: DisplayName = WindwardReports, Version=15.0.142.0, Culture=neutral, PublicKeyToken=34ffe15f4bbb8e53 (Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Office/Root/Office16/
LOG: Initial PrivatePath = NULL Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\\Program Files (x86)\\Microsoft Office\\Root\\Office16\\WINWORD.EXE.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Office/Root/Office16/WindwardReports.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Office/Root/Office16/WindwardReports/WindwardReports.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Office/Root/Office16/WindwardReports.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Office/Root/Office16/WindwardReports/WindwardReports.EXE.
이 같은 코드는 명령 줄 응용 프로그램에서 잘 작동합니다.
코드 : 다음은 코드입니다. (이 구문은 IKVM을 사용하여 .NET으로 바뀌었지만 실행중인 .NET 코드이므로 Java 코드이므로 약간 이상합니다.)
cli.System.Reflection.Assembly assm;
int indexSemi = outputBuilder.indexOf(';');
if (indexSemi != -1) {
String dllFilename = outputBuilder.substring (0, indexSemi);
outputBuilder = outputBuilder.substring(indexSemi + 1);
assm = cli.System.Reflection.Assembly.LoadFile(dllFilename);
}
else
assm = cli.System.Reflection.Assembly.GetExecutingAssembly();
cli.System.Runtime.Remoting.ObjectHandle hdl = cli.System.Activator.CreateInstance(assm.get_FullName(), outputBuilder);
return (IOutputBuilderEngine) hdl.Unwrap();
System.Activator.CreateInstance()는 예외를 발생시키는 것입니다.
코드를 게시 할 수 있습니까? – Aruna
@Aruna - 죄송합니다. 시작했을 때해야했습니다. 지금 거기. –
어셈블리 (A와 B 모두)는 어떻게 배치됩니까? 파일 시스템에 상주해야 할 위치는 무엇입니까? LoadFile 메서드에 대한 전체 경로를 전달하고 있습니까? – cynic