C# 在发布模式下,CompliationClass.GetAssembliesFile方法获取不同的文件集
我的windows应用程序对用户编写的代码进行运行时编译。 在调试模式下,CompilationClass实例获取应用程序所需的少量文件。 但在发布模式下,同一类实例从不同的位置获取文件,因此会发生错误 //只是一段代码示例C# 在发布模式下,CompliationClass.GetAssembliesFile方法获取不同的文件集,c#,.net,assemblies,dynamic-compilation,C#,.net,Assemblies,Dynamic Compilation,我的windows应用程序对用户编写的代码进行运行时编译。 在调试模式下,CompilationClass实例获取应用程序所需的少量文件。 但在发布模式下,同一类实例从不同的位置获取文件,因此会发生错误 //只是一段代码示例 CompilationClass cc = new CompilationClass(); List<string> TotalAssemblyFiles; public Form1() { TotalA
CompilationClass cc = new CompilationClass();
List<string> TotalAssemblyFiles;
public Form1()
{
TotalAssemblyFiles = cc.GetAssembliesFile(); // Error in this line
InitializeComponent();
}
CompilationClass cc=new CompilationClass();
列出所有文件;
公共表格1()
{
TotalAssemblyFiles=cc.GetAssemblysFile();//此行出错
初始化组件();
}
我不知道该怎么办。。问题仅在发布模式下发生。我甚至还没有指定任何路径
// Code for GetAssembliesFiles method
public List<string> GetAssembliesFile()
{
List<string> myAssemblies = new List<string>();
if (!File.Exists(Environment.CurrentDirectory + "\\assemblies.sft"))
{
// do nothing
}
else
{
BinaryFormatter binary = new BinaryFormatter();
Stream sreader = new FileStream(Environment.CurrentDirectory + "\\assemblies.sft", FileMode.Open);
myAssemblies = (List<string>)binary.Deserialize(sreader); // Issue
sreader.Close();
}
return refAssemblies;
}
//GetAssembliesFiles方法的代码
公共列表GetAssembliesFile()
{
List myAssemblies=new List();
如果(!File.Exists(Environment.CurrentDirectory+“\\assemblies.sft”))
{
//无所事事
}
其他的
{
BinaryFormatter binary=新的BinaryFormatter();
Stream sreader=new FileStream(Environment.CurrentDirectory+“\\assemblies.sft”,FileMode.Open);
MyAssembly=(列表)二进制。反序列化(sreader);//问题
sreader.Close();
}
返回重构;
}
在调试模式下,MyAssembly获取221个文件,而在发布模式下,它获取355个文件发布模式下的输出位置不同,它存储在“bin\release”中。程序集存储在哪里?位置仅为“bin\release”。。但是cc.GetAssembliesFile()从不同的位置获取文件,这与调试模式下的位置不同。如何获取程序集,请添加cc.GetAssembliesFile()实现?@aliseprehri.Kh-请参阅GetAssembliesFile()实现的代码在两种模式下检查Environment.CurrentDirectory的值。它们是一样的吗?