Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global Filter registering error on MVC 3 RC

I have a mvc 3 web app, but my shared web hosting company supports MVC 2 only. So I deploy mvc 3 related dlls too, and it had worked well on the server till it was mvc 3 beta.

Yesterday, I upgraded my pc environment to the mvc 3 RC and rebuilt my web app. The app works well on my local pc, but when i deploy and run on the hosting server, it makes an error.

[MissingMethodException: Method not found: 'Void System.Web.Mvc.GlobalFilterCollection.Add(System.Object)'.]
Myweb.MvcApplication.RegisterGlobalFilters(GlobalFilterCollection filters) in c:\my\Global.asax.cs:18
Myweb.MvcApplication.Application_Start() in c:\my\Global.asax.cs:36

As you see, when i try to register global filter in global.asax, it says it can't find Mvc.GlobalFilterCollection.Add(object) method.

If i do not register any global filter, the whole web works well on the hosting server.

How can I solve this error?

edit: It seems that the mvc3 beta is registered in the GAC of the hosting server. They said it's not, but i checked the location of the referenced System.Web.Mvc.dll in my app.

like image 234
tk. Avatar asked Nov 13 '10 01:11

tk.


1 Answers

From your description I looks like you have a mksmatch between the version of MVC 3 that you are using on your machine and the version that's uploaded to your server. We changed the parameters for GlobalFilterCollection.Add and it looks like you are compiling your application on your PC using MVC 3 RC, however you are deploying it to a sever that has MVC 3 Beta. Please make sure that the version of System.Web.Mvc.dll is the right one on your sever.

Edit: To confirm Eilon's comment, if MVC 3 Beta is installed into the GAC then it will always win, even if you have the RC version in your app's bin folder.

like image 151
marcind Avatar answered Oct 12 '22 09:10

marcind