I am trying out examples from a book. The first one is really simple .. a few lines of code in a view (MVC).
I run the code but get an error :
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0234: The type or namespace name 'Ajax' does not exist in the namespace 'System.Web.Mvc' (are you missing an assembly reference?)
Source Error:
Line 22: using System.Web.WebPages;
Line 23: using System.Web.Mvc;
Line 24: using System.Web.Mvc.Ajax;
Line 25: using System.Web.Mvc.Html;
Line 26: using System.Web.Routing;
Source File: c:\Users\Aindriu\AppData\Local\Temp\Temporary ASP.NET Files\root\6882868f\b519e811\App_Web_index.cshtml.a8d08dba.h-o4pos5.0.cs Line: 24
I fixed the problem - I right clicked the solution in Solution Properties (on the right) and selected Manage Nuget Packages - i typed in MVC on top right search bar - and installed MVC.... it installed a whole load of files and my program worked..... but it added code to the solution I am working on..
Is there a easy way to get around this error ? I don't want to have to keep doing this every time I create a MVC program...
If you are using Visual Studio, from the project's References select the System.Web.Mvc dll. At the Properties Window set the Copy Local attribute to True.
You could even copy the necessary references to the bin\Debug or bin\Release directory (whichever you would use) manually, but setting it to happen automatically by Visual Studio is far better.
With newer versions of MVC, the preferred method is to use the NuGet package manager. Under: View > Other Windows > Package Manager Console. Type:
Install-Package Microsoft.AspNet.Mvc -Version 4.5.1
You should do this for every Mvc project.
Related
I'm getting "The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)" from "using System.Windows.Forms;". Various people on the internet say to add it through a "References" tab in Solution explorer, but for me it's not present:
How do I get the references tab to appear, or how do I otherwise get "using System.Windows.Forms" to work?
Looking at core code examples of say... Edit Action for SpecificationAttribute. I am looking to replicate this delete function in the same manner in my plugin, however, getting an error.
Getting this error
'IHtmlHelper' does not contain a definition for 'DeleteConfirmation' and no extension method 'DeleteConfirmation' accepting a first argument of type 'IHtmlHelper' could be found (are you missing a using directive or an assembly reference?)
I have used in 3.90 but it getting error in 4.0 asp.net core Has anyone used #Html.DeleteConfirmation in a plugin (on administration side) that could give me a clues
I have a span element in the html like the following;
<span id="myattribute-delete" class="k-button">#T("Admin.Common.Delete")</span>
And trying to use #Html.DeleteConfirmation("myattribute-delete")
I know I probably need to double check my route, by the error is leading me to think the issue is not a routing issue.
As #Stephen stated it's not part of MVC, and it's custom helper by nopCommerce.
#Html.DeleteConfirmation is helper till/in nopCommerce 3.90, but in 4.0 it has been changed to
<nop-delete-confirmation asp-model-id="#Model.Id" asp-button-id="myattribute-delete" />
And that helper located at Nop.Web.Framework.TagHelpers.Adminso you have to add reference of it to your view file.
In section 5 of the ASP>NET MVC Music Store example, "Creating the StoreManagerController," when I click "Add" I get the error,
There was an error running the selected code generator:
'Unable to retrieve metadata for 'MVCMusicStore.Models.Album.'
The popular solution is to comment out the connection string in Web.config. This did not work for me. After trying many things I decided to add the code manually, by taking it from the completed code that's included with the example. When I do that I receive the error,
Compiler Error Message: CS0234: The type or namespace name 'Album' does not exist in the namespace 'MvcMusicStore.Models' (are you missing an assembly reference?)
and on line 31 I see the error,
public class _Page_Views_StoreManager_Index_cshtml : System.Web.Mvc.WebViewPage<IEnumerable<MvcMusicStore.Models.Album>>
Album is defined in the models folder. I have used webform development many times and am trying to add MVC to my repertoire. It seems to me "Album' is not registered, but I don't even know if that's appropriate lingo for MVC. What's the problem? I'm running this example in Visual Studio 2017.
The problem with line 31 is my project is named "MVCMusicStore". In the completed code I imported it's "MvcMusicStore". So it's looking at the wrong thing for the 'Album'namespace. Still don't know what causes the first error.
After correcting the namespace in the sample file, that error goes away and the new error is on the line;
#foreach (var item in Model{
the error is "System.NullReferenceException 'Object reference not set to an instance of an object.'
In Xamarin, I have added the "universal-image-loader-1.9.2-with-sources.jar" as a file in the "Jars" folder of a binding project, I have then built the application but I am getting one error.
Here is the error:
Error CS0234: The type or namespace name 'DiskLruCache' does not exist
in the namespace
'Com.Nostra13.Universalimageloader.Cache.Disc.Impl.Ext' (are you
missing an assembly reference?)
Can I please have some help to get this code working?
Thanks in advance
You need to add the binding project as a reference in your Startup project.
To do so click on References directory in you solution tree and select the binding project in the "Projects" tab.
Good luck!
You need to create the Bindings Library project and then add this jar into the folder Jars.
For fixing error:
The type or namespace name 'DiskLruCache' does not exist in the namespace 'Com.Nostra13.Universalimageloader.Cache.Disc.Impl.Ext'
add to Transforms\Metadata.xml
<attr path="/api/package[#name='com.nostra13.universalimageloader.cache.disc.impl.ext']/class[#name='DiskLruCache']" name="visibility">public</attr>
I'm on about page 70 of the NerdDinner tutorial (MVC 1.0 version). It won't build at this point because it is saying the properties referred to in the GetRuleViolations (ie, Title, Description, etc) can't be resolved. I've compared my own project with the downloadable source code and can't figure out what is missing. The error VS 2008 is giving me is "The name 'Title' does not exist in the current context". I can see the declarations in the NerDinner.designer.cs file.
Did you make sure to import the namespace of the model type?