Public Function GenerateScript(code As String) As IScript
Using provider As New VBCodeProvider()
Dim parameters As New CompilerParameters()
parameters.GenerateInMemory = True
parameters.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location)
Dim interfaceNamespace As String = GetType(IScript).Namespace
Dim codeArray() As String = New String() {"Imports " & interfaceNamespace & Environment.NewLine & code}
Dim results As CompilerResults = provider.CompileAssemblyFromSource(parameters, codeArray)
Return CType(results.CompiledAssembly.CreateInstance("Script"), IScript)
End Using
End Function
시간이 지나면 바뀔 수있는 문자열을 실행하려면 위 코드를 사용하고 있습니다. 그러나 이것을 실행할 때 다음 오류가 발생합니다.CodeDom 컴파일러가 DLL을 액세스하는 데 문제가 있습니다.
System.IO.FileNotFoundException: 'Could not load file or assembly 'file:///C:\Users\zjf\AppData\Local\Temp\ykujgxkp.dll' or one of its dependencies. The system cannot find the file specified.'
잘 모르겠습니다. 누구든지 제발 도와 주실 수 있습니까?
감사합니다.
'시스템이 지정된 파일을 찾을 수 없습니다. '- 파일이 없다는 것이 명백합니까? 그곳에 있다면 애플리케이션을 관리자로 실행하고 문제가 있는지 확인하는 것이 좋습니다. –
관리자와 함께 실행하면 동일한 일이 발생합니다. – zjf