Adding dll in web application which is developing on MVC Framework - asp.net-mvc

I have developed a custom Comment Control using class library file
now i want to use the dll of this file in web application which is developing on MVC Framework
so what are the ways of adding and using this dll in this project

MVC projects are no different from other project types. To add a reference to another assembly (DLL) you right click on our project in the solution explorer, select add reference and then select your dll file.

Related

Unable to add reference to certain assemblies in VS2015 MVC project

I am relatively new to MVC, so maybe I am missing something. I am using VS 2015 Community Edition, C# 2015 & .NET Framework 4.5.2.
I have an MVC solution with 2 projects: TLM and TLM.Tests. All the .cs files in both projects are happy with the following line of code:
using System.Data;
In fact, one of the .cshtml files has this line:
#using System.Data;
Now I add a 3rd project to the solution, a Class Library called TLM.Helpers, to hold commonly used code. (In ASP.NET web forms, it would have just gone in a .cs file in the App_Code folder.) However, I cannot add a using statement for System.Data to any of the .cs files in this project. In fact, I cannot even add a reference to that DLL in this project, although I see that there is such a reference in the other 2 projects.
That new project does have successful references to System, System.Collections.Generic, and System.Linq.
Other posts for similar issues suggest verifying that the project is being built for the proper Framework version. The Property page for this project does not even offer the choice of Target Framework. It does have dropdowns for "Solution DNX SDK version", which refers to "Version 1.0.0-beta5". I don't know what that refers to.
Any suggestions as to how I can refer to System.Data in this project?
Thanks.
Dan

How to add System.Web.Mvc version 5 to the project references

When I want to add System.Web.Mvc by right clicking the project and Add>Reference option, there is only version 3.0.0.0 and 4.0.0.0. However, I created the project as MVC 5. On the other hand, trying to add this reference on Nuget Package, there is no reference with the same name. Instead of this, there is another refernce named So:
1) How can add System.Web.Mvc (version 5 or later) reference to my projects including Class Library?
2) What is the difference between System.Web.Mvc and Microsoft.AspNet.Mvc?
Thanks in advance.
System.Web.Mvc Is one of the core namespaces developed by MS,it contains classes and interfaces that support the ASP.NET Model View Controller (MVC) framework for creating Web applications. This namespace includes classes that represent controllers, controller factories, action results, views, partial view, model binders, and much more. MS Link
Don't get confused with another namespace: Microsoft.Web.Mvcwhich contains classes that support the ASP.NET.MVC framework for creating web applications.
Now back to your first question about Microsoft.AspNet.Mvcthat you can download from Nuget. I think it's the same as System.web.mvc , if you check dll file it creates, you will notice that it has the exact samedll name: System.Web.Mvc.dll. It has the same size, assembly signature, etc.
I experienced this odd issue and had to uninstall/reinstall Microsoft ASP.NET MVC via NuGet Package Manager - for the project in question - before I could add the correct System.Web.Mvc v5.0.

Deploying a Solution with multiple projects on IIS7 - Missing DLLs

I'm trying to publish a solution that contains several projects -one of them is MVC- to IIS7.
When the MVC project is published and some views are being accessed I get the following error:
Could not load file or assembly 'NHibernate.Mapping.Attributes, Version=3.2.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The system cannot find the file specified.
This happens because the view I'm trying to access is calling a function in another project in that solution and needs this library!
but this library is not contained in the MVC project!
I was able to solve it by referencing that DLL in the MVC project! but I need another solution, because it doesn't make sense to reference every single DLL in all the other projects!
I'm using the "Web Deploy" publish option for the MVC project, is there another way that I can publish it and make it work without referencing all the DLLs from all the other projects?
There is an article on how to deploy assemblies that are not referenced by your MVC project directly:
http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx
Basically you need to create a folder in your project called _bin_deployableAssemblies and add your assemblies to it. They will get deployed with the website.
Here is a quote from the article:
So here’s the kicker. If you’re building a web application, and you
need an assembly deployed but don’t want it referenced and don’t want
it checked into the bin directory, you can simply add this folder
yourself and put your own assemblies in here.

How to setup EFP Entity Framework Profiler in a Silverlight Application

I can't add the reference to the HibernatingRhinos.Profiler.Appender.v4.0.dll in the silverlight application because it is not a silverlight dll? I can add it to the web project but then how do I reference the dll in the silveright App.xaml Application_Startup call.
See http://neverindoubtnet.blogspot.com.au/2011/03/efprof-first-look-profiling-devforce-sl.html
e.g. add the reference to your web project that hosts the silverlight control and then add the Initialize() method into your web project's global.asax Application_Start().
Entity Framework is on the server only, you don't need to add any references in the silverlight project. And HibernatingRhinos profiler is for NHibernate, not Entity Framework.
I don't understand what you are trying to do?
EFProf is an Entity Framework profiler from Hibernating Rhinos.
http://efprof.com/home

How do you activate the MVC templates in VS2008 from a WebForms App

I'm in the process of adding ASP.NET MVC to a WebForms app. One of the neat features of an ASP.NET MVC solution that you create from scratch is that a right click on the solution explorer and Add > New Item... will give a list of templates which include the MVC templates. However, in a WebForms app these templates don't appear.
I thought that there might be a setting in the .sln solution file that indicated that one was an ASP.NET MVC app but I couldn't find anything that that stuck out.
EDIT: To expand the question, how does Visual Studio know to add a "Controller..." menu item on to the "Add" menu when you right click on the Controllers folder in the Solution Explorer of an MVC app? Likewise it adds a "View..." menu item to the "Add" menu when you right click on the Views folder. Where does Visual Studio get this info from and how can I add those 2 folders to another web app and get the same functionality?
Ideas?
I believe that the logic for that is contained in the dll
Microsoft.VisualStudio.Web.ExtensionsUI
Which is registered in the Project template used when you create a new ASP.NET MVC project:
<WizardExtension>
<Assembly>
Microsoft.VisualStudio.Web.Extensions,
Version=9.0.0.0,
Culture=neutral,
PublicKeyToken=31bf3856ad364e35
</Assembly>
<FullClassName>
Microsoft.VisualStudio.Web.Mvc.TemplateWizard
</FullClassName>
</WizardExtension>
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\Web\1033\MvcWebApplicationProjectTemplatev1.cs.zip
You could probably also mess around with the Project Type Guids in your .xxproj file:
<ProjectTypeGuids>
{603c0e0b-db56-11dc-be95-000d561079b0};
{349c5851-65df-11da-9384-00065b846f21};
{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>
Seem to be the default ones for an ASP.NET MVC project, compare those with the ones in your web application, and go from there.
However, in a lot of these circumstances I'd agree with gisresearch: it's often easier to create the more complex project (the MVC one) first, and then move the origininal into it.
Also, there's nothing to stop you having multiple projects hosted in the same web application - pull the common logic from the web application into a shared class library, and then reference that from a clean MVC app, with a slightly different namespace, and then merge the two sites within IIS, drop the dlls into a shared bin folder (or strongly name them and put them in the global assembly cache), share the images/scripts, and away you go - you just need to take care with the Global.asax, which would be common to both.
How about the other way around. Create an asp.net mvc project firstly, and then add your web form code over.
Here is an example of hybrid app by Scott Hanselman.
You may also consider to create one default asp.net mvc application and asp.net web form application, and then do a text compare of two projects to see what is the difference.
Like Zhaph mentioned, adding the ProjectTypeGuid worked for me. Unload the web project, edit, and add in the extra ProjectTypeGuid to the existing list.
{603c0e0b-db56-11dc-be95-000d561079b0};

Resources