"The specified user does not have a valid profile. Unable to load " when dynmically loading assembly

Espen Johannessen 41 Reputation points
2020-01-10T10:05:45.9+00:00

I have a console app running .NET framework running as a web job.

A part of this job compiles some .cs-scripts at runtime, stores the compiled files in a directory, and loads them to invoke a method in the compiled script.

On local development environment and on standard windows server this works fine. But when running this on Azure as web job i get the error :

Error in method System.Reflection.RuntimeAssembly _nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean) of mscorlib.Message is: The specified user does not have a valid profile.  Unable to load 'file:///D:\home\site\jobs\triggered\BatchJobManager\BatchJobScriptsCompiled\CleanLogTables.csc

It is the same console app that creates and tries to load the compiled script.

I have tried to run the script from the KUDU-console with power-shell command Start-Process with option -LoadUserProfile, I have tried making an separate console-app that invokes this console app using StartInfo.LoadUserProfile = true from the System.Diagnostics.Process class, and I have tried to figure out if I can set the LoadUserProfile parameter in Azure that resembles the one used on IIS for setting loadUserProfile = true without any luck.

Anyone that has been in a similair scenario with this error message on web jobs that might help me progress?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,894 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jeremy Brooks 572 Reputation points Microsoft Employee
    2020-01-11T16:09:50.983+00:00

    I believe this is the configuration you are looking for that is configured through an app settings:

    • It needs to be explicitly turned on. This is done by setting an app setting called WEBSITE_LOAD_USER_PROFILE, with value 1
    • It is only available for sites running in Basic or Standard mode (i.e. which don't share their VM with others)

    https://github.com/projectkudu/kudu/wiki/Configurable-settings#add-user-profile-support-for-a-site

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.