如何添加使用rosyln compilrt创建的动态创建的程序集的引用。将汇编文件创建到文件系统之后。
string path = Path.Combine(tempDir, assemblyFileName);
var pdbFilePath = Path.Combine(tempDir, Path.GetFileNameWithoutExtension(assemblyFileName) + ".pdb");
emitResult = compilation.Emit(path, pdbFilePath);
重新运行应用程序会抛出异常。
Could not load file or assembly 'RunTimeRules.XRefRule' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
System.IO.FileLoadException: Could not load file or assembly 'Jpmc.Cib.Msr.RuleEngine.RunTimeRules.XRefRule' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
=== Pre-bind state information ===
LOG: DisplayName = Jpmc.Cib.Msr.RuleEngine.RunTimeRules.XRefRule
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Jpmc.Cib.Msr.RuleEngine.RunTimeRules.XRefRule | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Projects/RE/Jpmc.Cib.Msr.RuleEngine/
LOG: Initial PrivatePath = C:\Projects\RE\Jpmc.Cib.Msr.RuleEngine\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\RE\Jpmc.Cib.Msr.RuleEngine\web.config
LOG: Using host configuration file: H:\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/I705472/AppData/Local/Temp/Temporary ASP.NET Files/vs/e110b058/8e2e9773/Jpmc.Cib.Msr.RuleEngine.RunTimeRules.XRefRule.DLL.
LOG: Attempting download of new URL file:///C:/Users/I705472/AppData/Local/Temp/Temporary ASP.NET Files/vs/e110b058/8e2e9773/Jpmc.Cib.Msr.RuleEngine.RunTimeRules.XRefRule/Jpmc.Cib.Msr.RuleEngine.RunTimeRules.XRefRule.DLL.
LOG: Attempting download of new URL file:///C:/Projects/RE/Jpmc.Cib.Msr.RuleEngine/bin/Jpmc.Cib.Msr.RuleEngine.RunTimeRules.XRefRule.DLL.
WRN: Comparing the assembly name resulted in the mismatch: NAME
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
这个程序集是动态生成的程序集。我是否需要将其作为现有项目参考的一部分?因为它没有引用任何地方,但它的bin文件夹的一部分,所以它抛出异常