Installing a modified version of ASP.NET MVC - asp.net-mvc

I have made a relatively simple change to the MVC 1.0 source code to correct a bug in the DropDownList HtmlHelper (discussed in another question).
I was able to rebuild the MVC solution, ran all the tests, including the one I hadd added to show the bug I was fixing, and built a new DLL.
But how do I use that?
I tried moving the new MVC dll into the project and changing all the project references to point to it, but when I try to run the MVC website, it's throwing an exception saying there's a conflict between my version of MVC and the MVC in the GAC.
I tried to use gacutil.exe to remove the one from the GAC, but it says it can't do that because it would make another program (the Microsoft Installer? fail.
What do I have to do to install my newly built version in place of the "official" version?

If you want to remove it from the GAC without uninstalling MVC (which includes the Visual Studio templates you probably need), you need to do this in the registry:
Find registry key HKEY_CLASSES_ROOT\Installer\Assemblies\Global and look for key starting with System.Web.Mvc – delete it
Now you should be able to use gacutil.exe to remove System.Web.Mvc from the GAC, and you should be able to use your version from your /bin folder.

How about changing the version number when you compile the modified MVC framework?

Related

ASP.NET MVC source code missing solution file

I recently inherited some source code developed by someone else who is no longer with the company. However, the solution file was missing and I'm not even sure which version of MVC it was using. I'm experienced with ASP.NET, but not well-versed in MVC so I'm unsure how to go about rebuilding the solution the proper way. Looking for any tips/guidance on how to go about this.
Create a new, blank solution.
Open the solution in Windows Explorer.
Copy the project files into the solution folder.
Within Visual Studio, right-click the solution in Solution Explorer, and then chose the option to Add Existing Project....
Navigate to the solution folder (if necessary), and then select the .csproj (or .vbproj) file. The project will added into the solution.
Now, whether you can compile the solution/project depends on whether the version of MVC is compatible with the tooling installed in your instance of Visual Studio. If the project has NuGet dependencies, they should be restored the first time you build, depending (again) on your version of Visual Studio and tooling.
Edited:
Since you say that even the project file is missing, you can, assuming there are no external dependencies, create a new MVC project and then copy/paste the files into it (or drag & drop the files from Windows Explorer). Assuming there is a Views folder, it will have it's own web.config file. That config file will have bindings for the version of MVC the project was developed with.
MVC4 and newer projects tended to default to using Razor syntax, so the views will be littered with stuff like #Model. If it's using the older WebForms syntax (like <asp:ContentPlaceholder>), it's probably MVC3 or older.
Go to web.config file in the project and look for:
assembly="System.Web.Mvc,Version=3.0.0.0 ..."
In this example is.MVC 3, look for your version

MvcSiteMapProvider.dll not working in Visual Studio 2013

I have a MVC 2 project created in Visual Studio 2010 that use MvcSiteMapProvider.dll and works fine. But when loading the project in Visual Studio 2013, everything else work fine except it crashes at
Html.MvcSiteMap().SiteMapPath
The error message is
An exception of type 'MvcSiteMapProvider.MvcSiteMapException' occurred in MvcSiteMapProvider.dll but was not handled in user code
I believe that MvcSiteMapProvider.dll cannot be loaded correctly. I need help on this. Thanks.
Note that there is a separate DLL for each .NET framework version, and I suspect you are targeting the wrong framework. This can happen if you install MvcSiteMapProvider into your project and then change it to a different .NET framework version.
NuGet does not automatically upgrade/downgrade packages to the currently set framework version. This step must be done manually. The best way is to completely uninstall and reinstall the package as per this document. Also be sure to read this before attempting it.
But do note that if you do this NuGet will not remove any files you have changed (like Mvc.sitemap) and then prompt you whether to overwrite them. You should normally say no to each prompt to ensure your custom configuration is not overwritten.
Also note that it is not sufficient to use Assembly Binding Redirection with MvcSiteMapProvider because with each .NET framework version we create a separate build (DLL) that takes advantage of features that are not present in prior versions.

Missing reference to System.Web.Mvc in Asp.net Unit Test?

I recently made some unit tests for my Asp.NET MVC application, or I tried to, it keep telling me "The type 'System.Web.Mvc.Controller' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Mvc, Version=5.1.0.0, Culture=neutral.' Then I tried to add a reference to the above mentioned, but was only able to choose version 4.0.0.0 and now it tells me that my project already uses version 5.1.0.0, which is a higher version. What to do?
Thanks a bunch!
MVC 5 comes in from a NuGet package. Just as it did with the main MVC web project in your solution. Install MVC via NuGet into your Test project, and you should be good to go.
An educated guess, but you might have obtained the newer version via a nuget package(some of the newer MVC project templates do this), and thus it is not installed in GAC. Use the nuget package manager for the MVC project to determine if this is the case, and if so then mystery solved.
In the test project you can add the same package, or use the addreference->Browse to browse into the nuget dependencies and poke around under the MVC project till you find the DLL(it will be in the file system somewhere under SolutionName/MvcProjectName/packages).

Monodevelop MVC3 razor - what is the trick to get it to work?

I use monodevelop 3.0.4.7 and mono 2.11.4 on mac OS 10.8.
When I create a new solution from scratch in monodevelop I can create several types of ASP.NET mvc3 projects with razor views, but the projects get created with references to system.web.helpers and system.web.webpages that are "not available for Mono/.net 4.0 in mono 2.11.4" and won't build.
If I change my .net version to 4.5 in the project options I get the system.web.webpages reference resolved, and if I simply remove the reference to system.web.helpers I am able to build the default site. However, it is unable to make use of .cshtml views, it only looks for aspx views.
I have tried different things related to references and versions of mono, changing the viewengine to razor in global.asax.cs and even copied dll's from a windows-based asp.net mvc application, but something new breaks all the time.
It seems strange that there are project types included that don't work from scratch, so I'm guessing/hoping I'm missing something much simpler?
I was sitting with the exact same problem, on Linux though, so I decided to ask on the mono mailing list (see the answer to my question here: http://lists.ximian.com/pipermail/mono-list/2012-October/049022.html).
The short answer is: no, you're not missing anything simple.
Long version: The current version of mono is not compiling the System.Web.Helpers.dll, so you have to do some footwork your self, to get it compiled. That is described in the link above.
I guess we just have to wait a little longer before this becomes part of the mono framework :/
I happened across a solution for this issue here:
http://blog.miraclespain.com/archive/2013/Jun-24.html
Basically in xamarin studio you can add a version of nuget from the following add-in repository source:
http://mrward.github.com/monodevelop-nuget-addin-repository/4.0/main.mrep
Once nuget is installed, you can create a new mvc3 razor project, notice the missing references for system.web.helpers and system.web.pages and just remove them, then use nuget to add the microsoft aspnet web pages 2 package which solves the missing references.

Install ASP.Net MVC without administrator rights?

Unfortunately, my company's IT policy doesn't allow me admin privileges to my own machine. However, I want to start working ASP.Net MVC; but the installer won't install the framework w/o admin rights. Is there anyway I can install MVC manually; like copying relevant DLLs somewhere, etc. Any constructive advice is greatly appreciated.
You can download & compile ASP.NET MVC yourself - and either include it as a referenced project, or just grab the resulting binaries and add them to your project like any other DLL.
Look for the link to MVCBetaSource.zip on this page - it's a pretty straightforward build using Visual Studio, and (if I recall correctly) includes the few binaries (System.Web.Abstractions and System.Web.Routing) that aren't part of the MVC source itself.
As of preview 3 or 4, ASP.Net MVC became binnable. What I've done in my solutions is have a 'binary references' folder at the root of the solution and make references to those local files in each project that needs them. You should copy:
System.Web.Abstractions.dll
System.Web.Mvc.dll
System.Web.Routing.dll
Once done, refer to these assemblies and things should work just fine. The biggest hurdle you face is extracting them from the MSI.
MVC is bin deployable, so if .Net 3.5 is installed with SP1 you should be good. Just make sure you mvc dll gets put in your bin folder and deploys out. The tricky part is the wildcard in IIS6, IIS7 will do this automatically but for 6 you need to make a rule, good luck.

Resources