어디로 갈 지 잘 모르겠습니다. 전반적인 목적은 사용자 스크립트를 가져 와서 .NET 환경 내에서 실행할 수있게하는 것입니다. 필자는 자신의 어셈블리를로드하려고 시도하지 않으면 대부분의 코드를 작성하고 작동합니다. 그러나 사용자에게 시스템의 내부 부분에 대한 액세스 권한을 안전하게 부여하기 위해 프록시 DLL이 만들어졌습니다. 이것은 문제가있는 곳입니다.CompileAssemblyFromSource를 사용하여 사용자 지정 어셈블리로드
지금이 프록시 DLL에는 인터페이스가 하나 있습니다. 물론
System.IO.FileNotFoundException : Could not load file or assembly 'file:///C:\Users...\AppData\Local\Temp\scts5w5o.dll' or one of its dependencies. The system cannot find the file specified.
내 첫번째 생각은 "... 그리고 scts5w5o.dll은 무엇인가?": 위의 코드를 실행
는CompilerParameters options = new CompilerParameters();
options.GenerateExecutable = false;
options.GenerateInMemory = true;
options.ReferencedAssemblies.Add("System.dll");
options.ReferencedAssemblies.Add("ScriptProxy.dll");
Microsoft.CSharp.CSharpCodeProvider provider = new Microsoft.CSharp.CSharpCodeProvider();
CompilerResults result = provider.CompileAssemblyFromSource(options, script);
// This line here throws the error:
return result.CompiledAssembly;
, 다음과 같은 오류가 발생합니다
ScriptProxy.dll
이 제대로로드되지 않았습니까? 아니면 ScriptProxy.dll 자체가 임시 파일에있는 종속성을로드하려고 시도하고 있습니까? 아니면 완전히 다른 것입니까?
언급해야 할 것은 NUnit 테스트 러너에서이 코드를 실행하고 있습니다. 차이가 있는지 확실하지 않습니다.
그건 의미가 있습니다. 나는 이것을 지금 시험해 볼 것이다. –
말로 문제를 해결하지는 못했지만 실제로 도움이되는 진정한 오류 메시지를 얻는 데 도움이 되었기 때문에 이것을 답으로 표시 할 것입니다! –
그래서 어떻게 실제 문제를 해결합니까! – Moumit