मैं रनटाइम पर गतिशील असेंबली संकलित कर रहा हूं। इसे एक और डीएल संदर्भित करने की जरूरत है। सबकुछ ठीक से काम करता है, जब तक कि मैं अपने कंपाइलर पैरामीटर में आउटपुट एस्प्लोर सेट करता हूं। लेकिन जैसे ही मैं GenerateInMemory = true सेट करता हूं; यह विफल रहता है:रनटाइम पर कक्षा को संकलित करने में विफल रहता है जब कंपाइलर पैरामीटर। जेनरेटइन मेमरी == सत्य
var compilerParameters = new CompilerParameters();
if(compileInMemory)
compilerParameters.GenerateInMemory = true;
else
compilerParameters.OutputAssembly = "<my_dynamic_dll_path>";
compilerParameters.ReferencedAssemblies.Add("<other_dll_path>");
var compilerResults = new CSharpCodeProvider().CompileAssemblyFromDom(compilerParameters, codeCompileUnit);
// Here: compilerResults.Errors.HasErrors == false
foreach(var type in compilerResults.CompiledAssembly.GetTypes())
{
// Exception:
// Unable to load one or more of the requested types.
// Retrieve the LoaderExceptions property for more information.
}
लोडर अपवाद मुझे बता रहे हैं कि "other_dll" नहीं मिला। यह तब तक काम क्यों कर रहा है जब तक मैं स्मृति में संकलित नहीं करता और मुझे स्मृति में काम करने के लिए क्या करना है?
और यदि आप अन्य.dll के पथ को हार्ड-कोड करते हैं? –
मुझे खेद है, पथ पहले से ही हार्डकोड किया गया है - – tanascius