Microsoft Virtualization Discussions

Unable to generate a temporary class (result=1) error CS0016

bsti
9,981 Views

I have several automated processes that check and update snapmirror relationships all throughout the day.  Occasionally ( a few times a day), I see the following error when calling the Get-NaSnapmirror cmdlet:

Exception calling "GetSnapMirrorStatus" with "0" argument(s): "Unable to generate a temporary class (result=1). error CS0016: Could not write to output file 'c:\Users\snap_admin2\AppData\Local\Temp\icpn9kkl.dll ' -- 'Access is denied. ' "

StackTrace :

at System.Management.Automation.DotNetAdapter. AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)
at System.Management.Automation.DotNetAdapter. MethodInvokeDotNet(String methodName, Object target, MethodInformation[] methodInformation, Object [] arguments)
at System.Management.Automation.Adapter.BaseMethodInvoke(PSMethod method, Object[] arguments)

at System.Management.Automation.ParserOps.Call Method(Token token, Object target, String methodName, Object[] paramArray, Boolean callStatic, Object valueToSet)
at System.Management.Automation.MethodCallNode .InvokeMethod(Object target, Object[] arguments, Object value)
at System.Management.Automation.MethodCallNode .Execute(Array input, Pipe outputPipe, ExecutionContext context)
at System.Management.Automation.AssignmentStatementNode.Execute(Array input, Pipe outputPipe, ExecutionContext context)
at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement, Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)

WasThrownFromThrowStatement : False Message : Exception calling "GetSnapMirrorStatus" with "0" argument(s): "Unable to generate a temporary class (result=1). error CS0016: Could not write to output file 'c:\Users\snap_admin2\AppData\Local\Temp\icpn9kkl.dll
' -- 'Access is denied. '
"
InnerException : System.Management.Automation.CmdletInvocationException: Unable to generate a temporary class (result=1). error CS0016: Could not write to output file 'c:\Users\snap_admin2\AppData\Local\Temp\icpn9kkl.dll
' -- 'Access is denied. '
---> System.InvalidOperationException: Unable to generate a temporary class (result=1). error CS0016: Could not write to output file 'c:\Users\snap_admin2\AppData\Local\Temp\icpn9kkl.dll
' -- 'Access is denied. '

at DataONTAP.PowerShell.SDK.ConnectNaController.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
--- End of inner exception stack trace ---


at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorResults, Boolean enumerate)
at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()

Void ExecuteStatement(System.Management.Automatio
n.ParseTreeNode, System.Array, System.Management.
Automation.Internal.Pipe, System.Collections.Arra
yList ByRef, System.Management.Automation.Executi
onContext)
HelpLink :
Source : System.Management.Automation

Unfortunately, I don't have a reliable way to reproduce this, it just pops up ocassionally throughout the day.  I had an issue earlier I posted about with the Connect-NaController cmdlet, which was related to the XML parser in .NET.  This kind of has a similar ring to it.

Fortunately, the workaround for this is to simply run the process again.

6 REPLIES 6

timothyn
9,981 Views

Hi BSTI,

It looks like there is a problem writing to your temporary directory "c:\Users\snap_admin2\AppData\Local\Temp".  The fact that it occurs intermittently is a bit strange.  The first thing I would check is that you have some free space on your C:\ drive.  If you have less than a 1GB free you should definitely try to move some files off and run disk cleanup (don't turn on compression though!).

The next thing to look at is that you have write permission to that temporary directory.  Right click on the directory in explorer and select properties->security and make sure you have full control.

A couple more things:  Is "snap_admin2" a guest user?  Are you passing credentials to the "Connect-NaControllerCmdlet" or letting it connect with RPC?

Let me know what you find!

bsti
9,981 Views

Thanks for the suggestions!  If only it were that simple...

I have well over 10 GB of free space on the C: Drive, so that's not the issue.  snap_admin2 is a local administrator of the machine, so it has full rights to the whole machine.  Connect-NaController is using RPC, so it's passing the credentials of the account with it.  

timothyn
9,981 Views

Are you running a virus scanner on the system?  If so, which one?  Can you exclude either the temporary directory and powershell.exe from the scan list?  On 64 bit systems it's probably best to exclude both "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" and "C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe".  Also you may try disabling the virus scanner altogether temporarily to see if the problem persists.

Finally can you double check the security tab on the %temp% dir? I suspect that's not the problem, but it would be good to get it out of the way.

Thanks!

bsti
9,981 Views

Timothy,

We aren’t running any virus software on this machine. I’ve verified the account has full permissions to the temp directory.

timothyn
9,981 Views

Thanks for checking that information.  I'm having a hard time reproducing it here, but I'm certain that there is a problem with the .Net XML serialization which by default generates temporary assemblies on the fly.  It can be a little bit fragile, especially with background processes, so the problem might have something to do with the way you are scheduling the automated jobs, but it's difficult to say with any certainty.

Unfortunately in the meantime I don't really have a good workaround for you.  You might try making the scheduled tasks run sequentially rather than in parallel if there are many of them.

We're going to look into changing the serialization so that it is all generated at build time which should resolve this issue, as well as the issue you were seeing previously with the verbose switch to Connect-NaController.  I'll be sure to post here if we get a new build that might help you out.

bsti
9,981 Views

That sounds great. Thanks!

Public