CSharpCodeProvider冻结我的mvc应用程序

时间:2016-11-18 13:30:41

标签: c# csharpcodeprovider

我需要在运行时创建一些Dll文件。 Dll的生成正在生成,但似乎mvc应用程序在执行此代码后冻结。 在输出窗口中,我可以看到我的所有Dll都被卸载,之后它们都被加载了。 我做错了什么?

我的代码:

using (CSharpCodeProvider codeProvider = new CSharpCodeProvider())
        {
            CompilerParameters parameters = new CompilerParameters
            {
                ReferencedAssemblies =
                {
                    string.Format("{0}\\{1}", binDirectory, "SomeDll.dll")
                },
                GenerateExecutable = false,
                OutputAssembly = string.Format("{0}\\{1}", binDirectory, assemblyName)
            };

            var files = Directory.GetFiles(dataDirectory, "*.cs"); //get all generated cs files 

            var result = codeProvider.CompileAssemblyFromFile(parameters, files); //this line causes the application to freeze

            codeProvider.Dispose(); //not sure if this is necessary

            if (result.Errors.HasErrors)
            {
                throw new Exception(result.Errors.ToString());
            }
        }

我的输出:

  

' iisexpress.exe' (CLR v4.0.30319:   / LM / W3SVC / 2 / ROOT-1-131239474882606992):卸载   ' C:\的Windows \ Microsoft.Net \组件\ GAC_32 \的System.Web \ v4.0_4.0.0.0__b03f5f7f11d50a3a \ System.Web.dll中'

     

' iisexpress.exe' (CLR v4.0.30319:   / LM / W3SVC / 2 / ROOT-1-131239474882606992):卸载   ' C:\的Windows \ Microsoft.Net \组件\ GAC_MSIL \ SYSTEM \ v4.0_4.0.0.0__b77a5c561934e089 \ System.dll中'

     

' iisexpress.exe' (CLR v4.0.30319:   / LM / W3SVC / 2 / ROOT-1-131239474882606992):卸载   ' C:\的Windows \ Microsoft.Net \组件\ GAC_MSIL \ System.Core程序\ v4.0_4.0.0.0__b77a5c561934e089 \ System.Core.dll'

     

(等)

     

' iisexpress.exe' (CLR v4.0.30319:   / LM / W3SVC / 2 / ROOT-2-131239476152101487):已加载   ' C:\的Windows \ Microsoft.Net \组件\ GAC_32 \的System.Web \ v4.0_4.0.0.0__b03f5f7f11d50a3a \ System.Web.dll中&#39 ;.   跳过加载符号。模块已优化并且是调试器选项   ' Just My Code'已启用。

     

' iisexpress.exe' (CLR v4.0.30319:   / LM / W3SVC / 2 / ROOT-2-131239476152101487):已加载   ' C:\的Windows \ Microsoft.Net \组件\ GAC_MSIL \ SYSTEM \ v4.0_4.0.0.0__b77a5c561934e089 \ System.dll中&#39 ;.   跳过加载符号。模块已优化并且是调试器选项   ' Just My Code'已启用。

     

' iisexpress.exe' (CLR v4.0.30319:   / LM / W3SVC / 2 / ROOT-2-131239476152101487):已加载   ' C:\的Windows \ Microsoft.Net \组件\ GAC_MSIL \ System.Core程序\ v4.0_4.0.0.0__b77a5c561934e089 \ System.Core.dll&#39 ;.   跳过加载符号。模块已优化并且是调试器选项   ' Just My Code'已启用。

(等)

0 个答案:

没有答案