2

My WPF desktop PC application uses impersonation at several key moments for accessing a database and network files.

At some point JIT compiler attempts to load referenced dlls to satisfy the executing code and causes a "could not load assembly, access denied" exception. Up until this point, I had no need to give the impersonated user local permissions. That would currently fix the problem.

But I'd rather not add local permissions nor preload assemblies.

Is there a way to have JIT assembly loading happen as the original user?

I wish I could override some JitLoadAssembly method, impersonate my original user and call base.JitLoadAssembly. Does something like that exist?

Or any other solutions?

EDIT: I tried to play some games using AppDomain.CurrentDomain.AssemblyResolve to then impersonate my original user to handle loading assemblies. But for some reason my AssemblyResolve method is never called when I'm impersonating. I can't find a way to handle AssemblyResolve under impersonation. Any ideas about that?

4

0 回答 0