I don’t know what file and folder structure is needed for deploying a MVC 3 application to a web server. I’m unable to use Visual Studio to do deployment, so I’m trying to create the structure somewhat manually. What is the folder structure of a deployed MVC 3 application?
I began with:
.../appname/
*.dll
Web.Config
App_Data/ # nothing in this directory
Which didn’t work. The Exception being:
System.IO.FileNotFoundException: Could not load file or assembly ‘System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35’ or one of its dependencies. The system cannot find the file specified.
File name: ‘System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35’
at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) [0x00047] in /root/iws-snippets/mono-install-scripts/fedora/build/mono-2.10.8/mcs/class/corlib/System/AppDomain.cs:785
at System.AppDomain.Load (System.String assemblyString) [0x00000] in /root/iws-snippets/mono-install-scripts/fedora/build/mono-2.10.8/mcs/class/corlib/System/AppDomain.cs:762
at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string)
at System.Reflection.Assembly.Load (System.String assemblyString) [0x00000] in /root/iws-snippets/mono-install-scripts/fedora/build/mono-2.10.8/mcs/class/corlib/System.Reflection/Assembly.cs:540
at System.Web.Compilation.BuildManager.LoadAssembly (System.Web.Configuration.AssemblyInfo info, System.Collections.Generic.List`1 al) [0x00000] in /root/iws-snippets/mono-install-scripts/fedora/build/mono-2.10.8/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:1294
at System.Web.Compilation.BuildManager.GetReferencedAssemblies () [0x000b4] in /root/iws-snippets/mono-install-scripts/fedora/build/mono-2.10.8/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:1123
at System.Web.Compilation.BuildManager.CallPreStartMethods () [0x00013] in /root/iws-snippets/mono-install-scripts/fedora/build/mono-2.10.8/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:555
Now I’ve moved to:
.../appname/bin/
*.dll
Web.Config
App_Data/
But this fails with the Exception:
System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetExportedTypes () [0x00000] in /root/iws-snippets/mono-install-scripts/fedora/build/mono-2.10.8/mcs/class/corlib/System.Reflection/Assembly.cs:356
at System.Web.WebPages.ApplicationParts.ResourceAssembly.GetTypes () [0x00000] in :0
at System.Web.WebPages.ApplicationParts.ApplicationPartRegistry.Register (System.Web.WebPages.ApplicationPart applicationPart, System.Func`1 registerPageAction) [0x00000] in :0
at System.Web.WebPages.ApplicationParts.ApplicationPartRegistry.Register (System.Web.WebPages.ApplicationPart applicationPart) [0x00000] in :0
at System.Web.WebPages.ApplicationPart.Register (System.Web.WebPages.ApplicationPart applicationPart) [0x00000] in :0
at System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule () [0x00000] in :0
at System.Web.WebPages.Administration.PreApplicationStartCode.Start () [0x00000] in :0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000d5] in /root/iws-snippets/mono-install-scripts/fedora/build/mono-2.10.8/mcs/class/corlib/System.Reflection/MonoMethod.cs:226
I should mention that I’m attempting to deploy to mod_mono (Mono running on Apache – Cent OS 5). However, all documentation tells me that to deploy is exactly like deploying a standard MVC application to IIS. I’m hoping that the folder structure is the cause of my current errors. I do have Web.Helpers as a .dll in the deployment target.
The System.Web.Helpers assembly is part of Razor. Make sure that you have installed ASP.NET MVC 3 on your server or if you are doing bin deploying that this assembly and all its dependencies are present in the
binfolder of your application.