I have some problem with dynamic compile C# code. I have some provider property in my class:
static CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v4.0" } });
and I have some code to compile my code
var compile = provider.CompileAssemblyFromFile(compilerParameters, sourceFile);
Most offen this code just compile my code. But on one machine, when app run as Windows Service this method return exception:
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 System.IO.File.ReadAllBytes(String path)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames)
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile(CompilerParameters options, String[] fileNames)
I Want to debug CompileAssemblyFromFile. This project has .net 4.6 targer so I download source form here https://referencesource.microsoft.com/download.html. Next I check Debug->Options->General->Enable .NET Framework source stepping and Suppress JIT optimization on module load (Managed only), next check in Debug->Options->Symbols->Microsoft Symbol Server, next click Load all symbols, and reboot VS.
When I debug my code and clikc F11 a go to
next click F10
when I want to see compiler variable I type in Immediate Window
next when type F10 debug go out from CodeDOMProvider.cs to invoke of CompileAssemblyFromFile. I Want to debug all CompileAssemblyFromFile.
How can I debug this code? This look like pdb from MS Symbol Server not match. Can you help me? Thanks for Yours time.