views:

729

answers:

5

I recently uploaded my ASP.NET MVC 2 Preview 2/.NET 4 application (Built using VS 2010 Beta 2) to MaximumASP.com's beta websites and when I try to run it I get the following error:

CS0121: The call is ambiguous between the following methods or properties: 'System.Web.Mvc.Html.ChildActionExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string)' and 'Microsoft.Web.Mvc.ViewExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string)'

This error doesn't show up on my developer machine (Windows 7, VS 2010). Any idea what could be causing this?


UPDATE

I made sure that the .dlls I uploaded with my project are the ones that are working fine with Visual Studio 2010 Beta 2, but I still get the same error when I upload it to my host.

My host is using the newest version of ASP.NET MVC 2 (Beta), but I'm referencing the old Preview .dlls in my web.config and uploading them in the BIN folder, but still nothing.

-

+1  A: 

MVC is NOT supported in VS2010 ... So is this Preview 2 (Although RenderAction is part of MVC2 Beta?)?

http://haacked.com/archive/2009/11/17/asp.net-mvc-2-beta-released.aspx

Unfortunately, because Visual Studio 2010 Beta 2 and ASP.NET MVC 2 Beta share components which are currently not in sync, running ASP.NET MVC 2 Beta on VS10 Beta 2 is not supported.

Pino
So my host is running ASP.NET MVC 2 Beta, while my application is built using VS 2010 MVC (which is a a version older than MVC 2 Beta)?
Baddie
Potentially, can you find out what they are running?
Pino
A: 

Can you give us the output of typeof(Controller).Assembly.GlobalAssemblyCache, both on your dev machine and on your host? If your controller code is able to run, you can just Response.Write() it, then Response.End(). This will cause your view not to render, so hopefully you can avoid that error.

Edit:

Since your hoster has GACed the MVC binary, you need to compile your site against the same version of the binary that your hoster is using; bin-deployment won't work. If your hoster has installed MVC 2 Beta, you need to compile your site against the MVC 2 Beta binary. Unfortunately this means that you'll have to compile your site with VS2008 + MVC 2 Beta, as VS2010 Beta 2 includes MVC 2 Preview 2, which is an earlier version than what your hoster has deployed.

As a completely unsupported workaround that might make MVC 2 Beta run on VS2010 Beta 2, check this comment on Phil's blog. Note that I mean completely unsupported - it might affect other parts of VS, prevent uninstallation and require reformatting the machine, cause your machine to turn radioactive, etc.

Alternatively, smack your hoster for GAC-deploying Beta binaries and get them to un-GAC it. :) Then you can bin-deploy the particular binary you're compiling against.

Levi
They both return true.
Baddie
I'll contact my host and see what they have to say. I'm on a shared plan, so I don't think they'll do this just for me. But we'll see.
Baddie
I told my host, they said it'll take them 24-72 hours to figure out the issue. I went ahead and use Microsoft.Web.Mvc.ViewExtensions.RenderAction(Html everywhere I used a RenderAction as a workaround until they get back to me.
Baddie
A: 

Two things I can think of; First, you could make sure not to import one of the namespaces on all of the pages (eg, remove Microsoft.Web.Mvc.ViewExtensions from any <% Import %> statements and from the system.web/pages/namespaces area of the web.config. This unfortunately means that you can't easily reference the extension methods in that assembly however.

An alternative option provided on the MSDN forums would be to write an extension method of your own that just wraps the one you want to call and has a completely different name (eg, BaddieRenderAction()).

Neither option is all that great, but with the second option at least you can get up and running easily and then in the future when MVC 2 is released and your providers GACed assemblies don't cause a problem, you can do a Search and Replace for "BaddieRenderAction" -> "RenderAction" and it's all fixed.

Chris Shaffer
A: 

Rather than wrap the Render Action, just explicitly call the extension method as follows: Microsoft.Web.Mvc.ViewExtensions.RenderAction(Html, ...)

Leigh Alsteris
+1  A: 

In my case, removing the reference to the old Microsoft.Web.Mvc library from ASP.NET MVC 1 solved the problem.

hangy