c# - Sitecore 应用程序中的 CSC 编译器错误

标签 c# .net sitecore csc

我们遇到一个问题,即 Sitecore 中的编辑在内容编辑器中更改语言时遇到问题。

发生这种情况是因为未找到已编译的 dll。

Exception: System.IO.FileNotFoundException
Message: Could not find file 'C:\WINDOWS\TEMP\gwp5mkkl.dll'.
Source: mscorlib
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess 
access, Int32 rights, Boolean useRights, FileShare share, Int32 
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String 
msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess 
access, FileShare share, Int32 bufferSize, FileOptions options, String 
msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters 
options, String[] fileNames)
at 
Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters 
options, String[] sources)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.
Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters 
options, String[] sources)
at Sitecore.CodeDom.Compiler.CSharpCompiler.Compile(String sourceFile, 
String code, String assemblyFile, StringCollection referencedAssemblies)
at Sitecore.CodeDom.Compiler.CSharpCompiler.Compile(String code, 
StringCollection referencedAssemblies)
at Sitecore.CodeDom.Compiler.CSharpCompiler.SourceToMemory(String code, 
StringCollection referencedAssemblies)
at Sitecore.Web.UI.XmlControls.FolderControlSource.
BuildControlAssembly(XmlNode fileNode, String& assemblyKey, String& 
assemblyFile)
at Sitecore.Web.UI.XmlControls.FolderControlSource.
GetControlAssembly(String controlName, String& assemblyKey)
at Sitecore.Web.UI.XmlControls.FolderControlSource.ResolveType(String 
controlName, Boolean includeDynamicTypes)
at Sitecore.Web.UI.XmlControls.ControlSource.GetControlType(String 
namespacePrefix, String controlName, String mode, Boolean 
includeDynamicTypes)
at Sitecore.Web.UI.XmlControls.ControlFactory.GetControlType(String 
controlName, String mode, Boolean includeDynamicTypes)
at Sitecore.Web.UI.XmlControls.ControlFactory.GetControl(Control parent, 
String controlName, String mode, Object[] properties, AllowGenericControl 
allowGeneric)
at Sitecore.Shell.DefaultPage.OnInit(EventArgs e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Page.ProcessRequestMain(Boolean 
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

出现这种情况是因为csc.exe无法生成dll文件

Faulting application name: csc.exe, version: 4.6.1590.0, time stamp: 
0x5787f44f
Faulting module name: KERNELBASE.dll, version: 6.3.9600.17936, time 
stamp: 0x55a68e0c
Exception code: 0xc0000142
Fault offset: 0x00000000000ec4e0
Faulting process id: 0x3680
Faulting application start time: 0x01d37027490a9fd7
Faulting application path: 
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe
Faulting module path: KERNELBASE.dll
Report Id: 86b98dc0-dc1a-11e7-80f9-00155d003b30
Faulting package full name: 
Faulting package-relative application ID:

根据 Sitecore 支持,这是 .NET 的问题,因此,他们无法帮助解决问题。

你们有没有遇到过这样的事情?

我们已尝试重新安装 .Net 框架,但没有结果。

此问题会定期出现,出现时需要重新启动服务器。 IIS 重置 是不够的。这不是因为对 C:\temp 文件夹 的写入权限。该应用程序具有正确的访问权限,并且在大多数时间都可以正常工作。

有什么想法吗?

最佳答案

有点摸不着头脑,但是:

是否有某种后台进程在运行以锁定或删除 Windows 临时文件夹中的文件?

当您说 Sitecore 运行一段时间后会因该错误而中断时,这让我认为是某些原因导致您提到的运行时生成的 DLL 变得不可读。我能想到的最明显的解释是:

  • “文件从临时文件夹中删除”(可能是试图释放磁盘空间的进程?)
  • “文件被锁定,ASP.Net 无法读取”(可能是主动备份或病毒扫描进程?)

网站崩溃后引用的文件是否真实存在?如果是这样,可以像Process Explorer这样的东西吗?告诉你哪些任务锁定了它?如果它真的消失了,您能否应用一些审核来记录临时文件夹中发生的事情并查看哪些进程创建和删除了该文件?

关于c# - Sitecore 应用程序中的 CSC 编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48516723/

相关文章:

c# - 将通过 Reflection.Emit 生成的类型保存为代码文件 (.cs),而不是将其保存在 .dll 文件中

c# - C - 判断一个数是否为素数

c# - 关注 ListView 最后添加的项目

.net - mkbundle 未从当前目录找到依赖项

c# - 使用 char 值与 C# 中的变量名进行比较?

sitecore - 哪些配置设置会影响 Sitecore 图像大小调整中的 PNG 优化?

c# - 通过c#获取多个格式错误的cookie

c# - 查找总和为一个数字的所有组合

sitecore - 自动取消发布 sitecore 中的项目

asp.net-mvc - Sitecore 6.6、MVC 3 和 System.Web.Optimization?