CSC compiler error in Sitecore application

2

We have an issue where the editors in Sitecore experience trouble with change language in the Content Editor.

This happens because a compiled dll was not found.

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)

This occurs because the csc.exe fails to generate the dll file

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:

According to the Sitecore support this is an issue with the .NET and, therefore, they can't help to resolve the issue.

Have any of you guys experienced something like this?

We have tried reinstalling the .Net framework with no result.

This issue occurs periodically and when it does, it is necessary to restart the server. An IIS reset is not enough. It's not because of write access to the C:\temp folder. The application has the correct access and it does work for most of the time.

Any ideas?

c#
.net
sitecore
csc
asked on Stack Overflow Jan 30, 2018 by Dinirex • edited Feb 12, 2020 by Kate Orlova

2 Answers

0

Bit of a shot in the dark, but:

Is there some sort of background process running that locks or removes files in the Windows temp folder?

When you say Sitecore runs fine for a while but then will break with this error, that makes me think that something made the runtime-generated DLL you mention become unreadable. The most obvious explanations I can think of for that would be:

  • "files get deleted from the temp folder" (maybe a process trying to free up disk space?)
  • "the file becomes locked, and cannot be read by ASP.Net" (maybe an agressive backup or virus scanner process?)

Does the file referenced physically exist after the website has crashed? If so, can something like Process Explorer tell you what task(s) have locks against it? And if it really has disappeared, can you apply some auditing to log what goes on in the temp folder and see what processes create and remove this file?

answered on Stack Overflow Jan 30, 2018 by JermDavis
0

We are experiencing exactly the same issue with Sitecore, but we went a bit further in researching it.

To dynamically compile an assembly C# creates some files, including a .cs file, in the %SystemRoot%\Temp folder and runs csc.exe to compile it. By fiddling with Temp folder permissions we were able to retrieve all these files, we wanted to see if there is a compilation error of something.

However, it seems like there is no compilation error, but a csc.exe just doesn't get executed.

I.e. there is a file .out which contains all output from csc execution. When everything goes fine and DLL is correctly generated this output file looks like this:

c:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /t:library /utf8output /R:"D:\Data\www\website\bin\Sitecore.Forms.Core.dll" /R:"System.Data.dll" /R:"System.Web.dll" /R:"System.Web.Services.dll" /R:"System.Xml.dll" /R:"D:\Data\www\website\bin\Sitecore.Kernel.dll" /R:"D:\Data\www\website\bin\Sitecore.Client.dll" /R:"System.dll" /R:"System.Web.dll" /R:"D:\Data\www\website\bin\Sitecore.Social.Client.dll" /R:"D:\Data\www\website\bin\Sitecore.Social.Facebook.Client.dll" /R:"D:\Data\www\website\bin\Sitecore.Buckets.dll" /R:"D:\Data\www\website\bin\Sitecore.Shell.MarketingAutomation.dll" /out:"C:\Windows\TEMP\ysnuke5l.dll" /debug- /optimize+ /optimize  "C:\Windows\TEMP\ysnuke5l.0.cs"


Microsoft (R) Visual C# Compiler version 4.6.1099.0

for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.



This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

But, when csc is "stuck" and no DLL is generated, the same out file looks like this:

c:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /t:library /utf8output /R:"D:\Data\www\website\bin\Sitecore.Forms.Core.dll" /R:"System.Data.dll" /R:"System.Web.dll" /R:"System.Web.Services.dll" /R:"System.Xml.dll" /R:"D:\Data\www\website\bin\Sitecore.Kernel.dll" /R:"D:\Data\www\website\bin\Sitecore.Client.dll" /R:"System.dll" /R:"System.Web.dll" /R:"D:\Data\www\website\bin\Sitecore.Social.Client.dll" /R:"D:\Data\www\website\bin\Sitecore.Social.Facebook.Client.dll" /R:"D:\Data\www\website\bin\Sitecore.Buckets.dll" /R:"D:\Data\www\website\bin\Sitecore.Shell.MarketingAutomation.dll" /out:"C:\Windows\TEMP\tijeambw.dll" /debug- /optimize+ /optimize  "C:\Windows\TEMP\tijeambw.0.cs"

As you can see, there is no output from csc.exe... Like it has not ever been executed.

Not to mention, that *.cs file is totally file and if I run the above command line on the server it is compiled successfully and DLL is created as it should.

We still have no idea what causing this behaviour, so any suggestions are welcome.

P.S. And sorry for not really providing an answer...

answered on Stack Overflow Feb 19, 2018 by mcsdwarken • edited Feb 12, 2020 by Kate Orlova

User contributions licensed under CC BY-SA 3.0