문제

I am creating an assembly programaticly and I want to reference to dll that I have on the disk How to do that with this code.

AssemblyName assemblyNameObj = new AssemblyName(assemblyName);
AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyNameObj, AssemblyBuilderAccess.RunAndSave);
도움이 되었습니까?

해결책

"Referencing" the assembly is a compile time feature. Since this is a dynamically generated assembly, it doesn't exist at compile time.

You would need to use Assembly.Load or similar to load the assembly after you create it, then use Reflection to instantiate the appropriate types within that assembly.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top