Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sitecore 10.2 - Type initializer exception when executing script via WebAPI #1318

Open
larionovadaria opened this issue Nov 28, 2023 · 5 comments

Comments

@larionovadaria
Copy link

Expected Behavior

restfulv2 service works as expected right after deployment.

Actual Behavior

Similar to: #982

  • Couldn't reproduce locally, only on Azure.
  • Fix described here Sitecore 9 - Type initializer exception when executing script via WebAPI  #982 (comment) didn't help, but the issue completely disappears if you manually restart WebApp once again after deployment, which makes me think something happens during initialization.
  • Issue began to happen only after remoting restfulv2 service was enabled. Sitecore Powershell itself worked without any issues on current version and previous ones.

Setup

Sitecore PowerShell Extensions 6.3.0.17327
Sitecore 10.2
Azure WebApp hosting

Steps to Reproduce the Problem

Steps to reproduce are similar to: #982

@michaellwest
Copy link
Member

Is there something you're using with that endpoint that could be shifted over to the SPE Remoting endpoint?

@larionovadaria
Copy link
Author

I think technically we could use SPE Remoting, but chose WebAPI instead to restrict running any script, and run only ones that we have predefined.
Are you saying that we need to try to move to SPE Remoting and see if issue persists?

@michaellwest
Copy link
Member

I'm curious if running the scripts through SPE Remoting encounters the same initialization error.

Can you try something like this with SPE Remoting (and restfulv2 disabled)?

Import-Module -Name SPE
$session = New-ScriptSession -Username admin -Password b -ConnectionUri https://remotesitecore
Invoke-RemoteScript -Session $session -ScriptBlock {
        # Your script
        # or Get-Item -Path "your-script" | Invoke-Script
}
Stop-ScriptSession -Session $session

@larionovadaria
Copy link
Author

The issue I described happens from time to time after deployment, locally it was never a problem.
I'll try to do what you proposed, will monitor WebApp for a while and return back. Thank you.

@larionovadaria
Copy link
Author

larionovadaria commented Oct 11, 2024

@michaellwest we disabled restful2 and used remoting script like you shared above. Unfortunately that didn't help, we still experiencing the problem.

Few things I've noticed. The restful2 and remoting was enabled on several Azure environments. Enabling of the services doesn't cause the issue itself. Only one environment has the issue above. That's the environment where we run package installation from Powershell regularly. So it seems like the package installation does something that causes the issue, but that's a guess.

So the sequence to reproduce is the following:

  1. Run package installation via Powershell on the environment. Wait till it successfully finishes the installation.
  2. Restart the app (manually restart web app or deploy new code which will restart the pool)
  3. Click on Desktop - Installation Wizard. It will show modal window with "The type initializer for 'Sitecore.Install.Serialization.IOUtils' threw an exception". Same error you'll get if you try to run package installation through Powershell.
  4. Restart web app in Azure
  5. Click on Desktop - Installation Wizard. If it doesn't return the issue anymore then the Powershell installation script will work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants