我正在尝试序列化动态生成/编译的程序集以存储到 SQL 中,然后提取程序集以供使用。但是,我遇到了一个让我发疯的错误。
"无法加载文件或程序集 '<random code>,Version=0.0.0.0,Culture=neutral,PublicKeyToken=null' 或其依赖项之一。系统找不到指定的文件。 "
当我尝试对程序集进行反序列化时。将不胜感激任何指针。部分代码:
'--------------------------------------------------------------
'This section SUCCESSFULLY Compile & Execute the Dynamic Code
' vsResult returns ok.
' **Note: This is partial code to create the compiler.
'--------------------------------------------------------------
Dim voCompileResults As System.CodeDom.Compiler.CompilerResults = voCompiler.CompileAssemblyFromSource(voCompilerParams, sb.ToString)
Dim voAssembly As Reflection.Assembly = voCompileResults.CompiledAssembly
Dim voInstance As Object = Activator.CreateInstance(voAssembly.GetType("libARules.clsMyRoutine"), {New libARules.Sys.clsInterProcessData(New System.Xml.XmlDocument), New libArrowOps.clsDBAccess})
Dim vsResult As String = voInstance.GetType().InvokeMember("Run", Reflection.BindingFlags.InvokeMethod, Nothing, voInstance, Nothing)
'----------------------------------------------------
'Attempt to Serialize the Assembly for store/forward
'----------------------------------------------------
Dim voMemStream As New IO.MemoryStream
Dim voBF As New Runtime.Serialization.Formatters.Binary.BinaryFormatter
voBF.AssemblyFormat = Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple
voBF.Serialize(voMemStream, voCompileResults.CompiledAssembly)
'--------------------------------------
'Reset the MemoryStream position to begining
'--------------------------------------
voMemStream.Position = 0
'--------------------------------------
'Attempt to De-Serialize the MemoryStream back to an assembly
'--------------------------------------
voBF = New Runtime.Serialization.Formatters.Binary.BinaryFormatter
voBF.AssemblyFormat = Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple
voAssembly = voBF.Deserialize(voMemStream)
'----- **Error Here** ---------------------------------
ERROR 此时:在线voAssembly = voBF.Deserialize(voMemStream)
无法加载文件或程序集 '...<random code>..., Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' 或其依赖项之一。系统找不到指定的文件。