Razor View Reference Error: FileNotFoundException - asp.net-mvc

I just got to fix the old project from other guys which use visual studio 2012. I think it was built on MVC4 because it still uses WebMatrix.Data and WebMatrix.WebData. Because I don't have that vs version so I was using visual studio 2013 community edition and run install-package update. After couple fixes, I got this problem when I tried to run it. The following is the error messages:
Server Error in '/' Application.
Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or
assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system
cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the exception
can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine
why the assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = System.Web.Razor, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///D:/BitBucketGit/DirtOilGas.Website/
LOG: Initial PrivatePath = D:\BitBucketGit\DirtOilGas.Website\bin
Calling assembly : System.Web.WebPages.Razor, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\BitBucketGit
\DirtOilGas.Website\web.config
LOG: Using host configuration file: C:\Users\amie\Documents\IISExpress
\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET
\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Razor, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET
/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a
/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET
/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a
/System.Web.Razor/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///D:/BitBucketGit
/DirtOilGas.Website/bin/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///D:/BitBucketGit
/DirtOilGas.Website/bin/System.Web.Razor/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET
/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a
/System.Web.Razor.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET
/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a
/System.Web.Razor/System.Web.Razor.EXE.
LOG: Attempting download of new URL file:///D:/BitBucketGit
/DirtOilGas.Website/bin/System.Web.Razor.EXE.
LOG: Attempting download of new URL file:///D:/BitBucketGit
/DirtOilGas.Website/bin/System.Web.Razor/System.Web.Razor.EXE.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'System.Web.Razor,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one
of its dependencies. The system cannot find the file specified.]
WebMatrix.WebData.PreApplicationStartCode.Start() +0
[InvalidOperationException: The pre-application start initialization method
Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception
with the following error message: Could not load file or assembly
'System.Web.Razor, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system
cannot find the file specified..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1
methods, Func`1 setHostingEnvironmentCultures) +547
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1
methods) +132
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String
preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
appManager, IApplicationHost appHost, IConfigMapPathFactory
configMapPathFactory, HostingEnvironmentParameters hostingParameters,
PolicyLevel policyLevel, Exception appDomainCreationException) +521
[HttpException (0x80004005): The pre-application start initialization method
Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception
with the following error message: Could not load file or assembly
'System.Web.Razor, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system
cannot find the file specified..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930508
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +254
Server Error in '/' Application.
Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///D:/BitBucketGit/DirtOilGas.Website/
LOG: Initial PrivatePath = D:\BitBucketGit\DirtOilGas.Website\bin
Calling assembly : System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\BitBucketGit\DirtOilGas.Website\web.config
LOG: Using host configuration file: C:\Users\amie\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a/System.Web.Razor/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///D:/BitBucketGit/DirtOilGas.Website/bin/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///D:/BitBucketGit/DirtOilGas.Website/bin/System.Web.Razor/System.Web.Razor.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a/System.Web.Razor.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/86bf6c81/eeee762a/System.Web.Razor/System.Web.Razor.EXE.
LOG: Attempting download of new URL file:///D:/BitBucketGit/DirtOilGas.Website/bin/System.Web.Razor.EXE.
LOG: Attempting download of new URL file:///D:/BitBucketGit/DirtOilGas.Website/bin/System.Web.Razor/System.Web.Razor.EXE.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
WebMatrix.WebData.PreApplicationStartCode.Start() +0
[InvalidOperationException: The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +547
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521
[HttpException (0x80004005): The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930508
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Manual solution findings may take time. Just Right click project and click 'Manage Nuget Packages' , search 'Microsoft ASP.NET Razor' and install version 3.2.3. it will update required assemblies and references.
Hope it will help you.

Related

System.TypeInitializationException: error thrown when i try to push into git

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Microsoft.Alm.Cli.Program' threw an exception. ---> System.TypeLoadException: Could not load type 'System.Collections.Generic.IReadOnlyList`1' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at Microsoft.Alm.Cli.Program..cctor()
--- End of inner exception stack trace ---
at Microsoft.Alm.Cli.Program.Main(String[] args)
error: unable to read askpass response from 'C:/Program Files/Git/mingw64/libexec/git-core/git-gui--askpass'
why is this error being thrown

The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception

I'm trying to run an ASP MVC 4 application on IIS. When I publish MVC 4 application from Basic template - without any dependencies apart from these made by the wizard - application works. But when I publish other application, that is using WebActivator and many other libs, I see this error:
Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
And complete stack trace:
[FileLoadException: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +180
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +192
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +115
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +426
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103
System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit) +64
WebActivator.AssemblyExtensions.GetActivationAttributes(Assembly assembly) +113
WebActivator.ActivationManager.RunActivationMethods() +216
WebActivator.ActivationManager.RunPreStartMethods() +28
WebActivator.ActivationManager.Run() +55
[InvalidOperationException: The pre-application start initialization
method Run on type WebActivator.ActivationManager threw an exception
with the following error message: Could not load file or assembly
'System.Core, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its
dependencies. The given assembly name or codebase was invalid.
(Exception from HRESULT: 0x80131047).]
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1
methods) +423
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
appManager, IApplicationHost appHost, IConfigMapPathFactory
configMapPathFactory, HostingEnvironmentParameters hostingParameters,
PolicyLevel policyLevel, Exception appDomainCreationException) +591
[HttpException (0x80004005): The pre-application start initialization
method Run on type WebActivator.ActivationManager threw an exception
with the following error message: Could not load file or assembly
'System.Core, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its
dependencies. The given assembly name or codebase was invalid.
(Exception from HRESULT: 0x80131047).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8946484
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
+258
Is is IIS6 related issue, or I'm missing something on the server?

Deploying MVC web site to Azure

I'm getting an error when I deploy a fresh MVC 3 web app to Azure. Though the site appears to work there are role initialisation errors meaning that the deployment from VS2010 never completes. (See output below.)
I suspect the Mindscape.Lightspeed.Web assembly is dependent on MVC 2. But I thought the following config section would override it.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
You can simulate this with an Azure project by uninstalling MVC 2 from your development system and then running in the development fabric.
How can I fix this?
Microsoft.WindowsAzure.ServiceRuntime Critical: 201 : 'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\1001b7f1\d3c78bbf\assembly\dl3\d2532ce7\a08fd830_9d4bcd01\Microsoft.WindowsAzure.Configuration.DLL'
Role entrypoint could not be created:
System.TypeLoadException: Unable to load the role entry point due to the following exceptions:
-- System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
=== Pre-bind state information ===
LOG: User = DiscoveryOne\scott
LOG: DisplayName = System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Users/scott/Documents/Visual Studio 2010/Projects/Teto.Azure/Teto.Azure/csx/Debug/roles/Teto.Web/approot/bin
LOG: Initial PrivatePath = C:\Users\scott\Documents\Visual Studio 2010\Projects\Teto.Azure\Teto.Azure\csx\Debug\roles\Teto.Web\approot\bin
Calling assembly : Mindscape.LightSpeed.Web, Version=4.0.1351.20441, Culture=neutral, PublicKeyToken=360c8f37b466ebb2.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/scott/Documents/Visual Studio 2010/Projects/Teto.Azure/Teto.Azure/csx/Debug/roles/Teto.Web/approot/bin/System.Web.Mvc.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
The program '[1564] WaIISHost.exe: Program Trace' has exited with code 0 (0x0).
The program '[1564] WaIISHost.exe: Managed (v4.0.30319)' has exited with code -1 (0xffffffff).
The assembly redirect should be fine, but don't forget that you might need to configure it in multiple files:
Web.config
Views\Web.config
WaIISHost.exe.config
You'll need to make sure you modify both Web.config files. If you're calling that LightSpeed assembly from your WebRole.cs file, I suggest you create a new file called WeIISHost.exe.config, add the redirect and set it the Copy to Output Directory to always. This is required because the WebRole now uses full IIS.
Have you checked to make sure Lightspeed is configured to run in Partial Trust mode?
http://www.mindscapehq.com/blog/index.php/2010/01/13/the-dynamic-duo-lightspeed-azure

MVC .NET + Server deployment issue

I have uploaded my database as well as files to server using FTP995. I am using the hosting server Go Daddy and they have trust level as Medium for all applications they support,
When I try to run my site, it is not even showing me a login page...
throwing exception
System.Security.Policy.PolicyException: Required permissions cannot be acquired.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack trace:
[PolicyException: Required permissions cannot be acquired.]
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +7606579
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57
[FileLoadException: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54
System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +600
System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +128
System.Web.Compilation.BuildManager.CompileResourcesDirectory() +31
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +304
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8894031
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259
....................................................................................
After that I have put trust level = "Medium", <trust level="Medium" /> into my web.config and deployed again..
Then showing error as
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: This configuration section cannot be used at
this path. This happens when the site administrator has locked access
to this section using from an
inherited configuration file.
Source Error:
Line 157: <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 158: </httpModules>
Line 159: <trust level="Full" />
Line 160: </system.web>
Line 161: <system.codedom>
Source File: D:\Hosting\7734726\html\web.config Line: 159
Read the error message.
[FileLoadException: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
Your trying to use an assembly in medium trust that won't work in medium trust. (Microsoft.ReportViewer.Common)
3 solutions
A) Ask your hosting provider to install the Microsoft.ReportViewer assemblies into the GAC (this may help), but they will probably be reluctant to do this
B)Find a new hosting environment with full trust or similar
or
B)Rewrite your application to not depend on that assembly.
If you are developing an application that will be deployed into a medium trust environment, you should of set trust="medium" while you were developing the application, so that you would of discovered any such issues during development instead of deployment.
Have you tried deploying your site directly from your visual studio publishing feature?
It may be that your FTP client is setting the wrong permissions.
If your reporting assembly can't run in media trust then go get a better hosting provider there are lots of them out there :)

Could not load file or assembly error in ASP.NET when IIS server is idle

I am using ASP.NET MVC technology to create a website. The site is hosted on IIS 7 server. If the site is not accessed for a while i get the "Could not load file or assembly error " . The error disappears after a single page refresh. I know the DLL is formed as part of project structure automatically by Asp.Net MVC Model. FS is the projects name
The complete error is below.
A web search did not produce a permanent solution to this problem. It would be great If any one has some fix for this issue.
Thanks in advance.
Could not load file or assembly 'FS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. HTTP download of assemblies has been disabled for this appdomain. (Exception from HRESULT: 0x80131048)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'FS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. HTTP download of assemblies has been disabled for this appdomain. (Exception from HRESULT: 0x80131048)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[FileLoadException: Could not load file or assembly 'FS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. HTTP download of assemblies has been disabled for this appdomain. (Exception from HRESULT: 0x80131048)]
System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean ignoreCase) +0
System.Reflection.Assembly.GetType(String name) +25
System.Web.Compilation.BaseTemplateBuildProvider.GetGeneratedType(CompilerResults results) +55
System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results) +45
System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results) +13
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +275
System.Web.Compilation.BuildManager.CompileGlobalAsax() +52
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +337
[HttpException (0x80004005): Could not load file or assembly 'FS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. HTTP download of assemblies has been disabled for this appdomain. (Exception from HRESULT: 0x80131048)]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729
[HttpException (0x80004005): Could not load file or assembly 'FS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. HTTP download of assemblies has been disabled for this appdomain. (Exception from HRESULT: 0x80131048)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8890735
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +333

Resources