I have recently purchased shared windows hosting with Plesk panel. The moment I uploaded the build in the server, it genuinely rejected exe files. When I consulted the provided, they gave me a shocking reply that under shared hosting due to security policy they reject exe files.
If I am not wrong dot net requires some exe files to compile runtime. So my question was Is there a way to host the application without default Roslyn exe files" so that my application can run in shared hosting. Also, I am using @Partial('') to render pages dynamically.
Below was the error that I have received when surfing the uploaded code.
[FileNotFoundException: Could not find file 'D:\Inetpub\vhosts\domain\bin\roslyn\csc.exe'.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +519
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) +776
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +65
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.get_CompilerName() +91
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch(CompilerParameters options, String[] fileNames) +656
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames) +186
System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile(CompilerParameters options, String[] fileNames) +24
System.Web.Compilation.AssemblyBuilder.Compile() +950
System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +10199289
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +10104232
System.Web.Compilation.BuildManager.CompileGlobalAsax() +44
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +260
[HttpException (0x80004005): Could not find file 'D:\Inetpub\vhosts\domain\bin\roslyn\csc.exe'.]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +62
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +435
System.Web.Compilation.BuildManager.CallAppInitializeMethod() +33
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +563
[HttpException (0x80004005): Could not find file 'D:\Inetpub\vhosts\domain\bin\roslyn\csc.exe'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10072580
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
After hours I was able to figure out the issue for my own question
Is there a way to host the application without default Roslyn exe files?
Yes we can publish the application without entire Roslyn folder and also we can use the cshtml Razor page templates like Partial render and others by performing the below steps
<compilation debug="true" targetFramework="4.7.2">
<assemblies>
<add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/>
</assemblies>
</compilation>
Explanation
By performing the above changes while creating a publish build entire Roslyn folder under the bin will be removed and during runtime the IIS will not look for csc.exe to compile the runtime instead it will use netstandard lib to perform the same. And Considering startup companies you can use this method to enjoy hasslefree hosting with windows shared hosting.
User contributions licensed under CC BY-SA 3.0