after I deployed the application to IIS7 server, it seems fine at the beginning and can display the login page. But after the user inputted the username and password, I have to authenticate the user with the DB connection. At this time, it display error (attached). I guess the error is caused by the reflection during the EntityFramwork load the DB data.
My server has been installed .net framework 3.5 sp1 already.
On the other hand, I have tried another server. If a server has been installed VS2008 and MVC2 package for VS2008, that server can run the application properly in IIS7.
My aim is to run the application on a IIS7 server with .net framework 3.5 only.
Please help me solve this problem.
The error datails:
Server Error in '/FDDV_demo' Application.
--------------------------------------------------------------------------------
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
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.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
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:
[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark) +0
System.Reflection.Assembly.GetTypes() +111
System.Data.Metadata.Edm.AssemblyCacheEntry.LoadTypesFromAssembly(LoadingContext context) +28
S开发者_开发百科ystem.Data.Metadata.Edm.AssemblyCacheEntry.InternalLoadAssemblyFromCache(LoadingContext context) +290
System.Data.Metadata.Edm.AssemblyCacheEntry.LoadAssemblyFromCache(Assembly assembly, Boolean loadReferencedAssemblies, Dictionary`2 knownAssemblies, Dictionary`2& typesInLoading, List`1& errors) +137
System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies) +284
System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyForType(Type type) +33
System.Data.Metadata.Edm.MetadataWorkspace.LoadAssemblyForType(Type type, Assembly callingAssembly) +80
System.Data.Objects.ObjectContext.CreateQuery(String queryString, ObjectParameter[] parameters) +106
FDDV.Models.DBEntities.get_user_master() +113
FDDV.Controllers.HomeController.validateUser(String userid, String password) +254
FDDV.Controllers.HomeController.LogOn(LogOnModel model, String returnUrl) +134
lambda_method(ExecutionScope , ControllerBase , Object[] ) +136
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24
System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() +53
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +258
System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +193
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +316
System.Web.Mvc.Controller.ExecuteCore() +104
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +36
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +53
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +43
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8682542
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955
I finally solved this problem. The main cause is the project missed some assembly references. I add the following code to the login function to find out the reflection type load exception. Once again, thanks everyone 's helpful
try{
//Do your work
}
catch (Exception ex)
{
ReflectionTypeLoadException exception = ex as ReflectionTypeLoadException;
if (exception == null)
System.IO.File.AppendAllText("C:\\TestLog.txt", "Not a ReflectionTypeLoadException ex.");
else
{
foreach (Exception loaderException in exception.LoaderExceptions)
{
System.IO.File.AppendAllText("C:\\TestLog.txt", loaderException.Message);
System.IO.File.AppendAllText("C:\\TestLog.txt", loaderException.StackTrace);
}
}
return true;
}
I faintly recall having a similar issue with MVC 3 when I upgraded a project from MVC 2 and had some version issues in my web.config
.
Try enabling fusion assembly log binding and see if you can find maybe what the load is failing on.
http://www.hanselman.com/blog/BackToBasicsUsingFusionLogViewerToDebugObscureLoaderErrors.aspx
I found a script a while back that allowed me to work with fusion log better in IIS (I was having problems where it didn't run in IIS).
精彩评论