I have a tool that is written in .NET 4.5.2 that generates proxy output files using reflection. You point the tool to a DLL and it generates the output.
It loads the Assembly or EXE using Assembly.Load, however when pointing it at an ASP.NET Core 1.0 RTM application that is compiled with the 4.5.2 framework (the output in the \bin\Debug\net452 folder), it gets the following exception:
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'http://file/C:\Code\Test452Web\bin\Debug\net452\Test452Web.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at TypeScriptTypingsGenerator.Program.Main(String[] args) in C:\Code\TypeScriptTypingsGenerator\TypeScriptTypingsGenerator\Program.cs:line 31
Since the ASP.NET CORE application is compiled in 4.5.2 as well, I think it should be able to be loaded into the AppDomain. What is the proper way to do this?
Aucun commentaire:
Enregistrer un commentaire