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.'
Related
Almost always when I close a project in Visual Studio, it almost alwyas have these types of errors (written down below) when I open the project again, even if it didn`t have any errors when I closed the program. Anyone who knows why this happens and how I could fix it?
Error CS0101 The namespace 'uppdrag_2.cs' already contains a definition for 'Program'
Error CS0101 The namespace 'uppdrag_2.cs' already contains a definition for 'SecondClass'
Error CS0111 Type 'Program' already defines a member called 'Main' with the same parameter types
Error CS0111 Type 'Program' already defines a member called 'Newcustomer' with the same parameter types
Error CS0121 The call is ambiguous between the following methods or properties: 'Program.Newcustomer()' and 'Program.Newcustomer()'
Thank you in advance!
//Johanna
This is an ASP.NET (Framework v. 4.5.2) website currently running reliably in production. A new requirement called for adding a new column to an existing SQL Server table (apProduct) which has been done. I then made the necessary changes to the .edmx file, controllers, views, etc., and everything is compiling fine. However I'm now getting the runtime error below:
When I debug and set a breakpoint where apDepartment is first getting created, I expand the created objects and see this:
My attention is drawn to: "The metadata for 'EntityFrameworkDynamicProxies-AnkoMVC' is invalid."
Here is where apProduct is defined, clearly within the AnkoMVC.Models namespace:
Lastly, here is the DbContext class:
Can anyone offer suggestions on how to overcome this?
I found the problem in the #model reference in many of the views. Here is the faulty code:
This is the corrected #model reference:
Thanks!
I am getting this error:
Error 40 The type or namespace name 'ViewAsPdf' does not exist in the
namespace 'Rotativa' (are you missing an assembly
reference?) D:\SandeepPatil\PPD_Projects\Code\Karma_Retail\Karma.Store\Areas\Admin\Controllers\OrderController.cs 1757 45 Karma.Retail.Web
You may be missing the reference to the Rotativa dll which was reported as an error in version 1.7.3, found here. There's now a prerelease version 1.7.4-rc which presumably fixes this issue.
This error is caused by trying to instantiate a Rotativa.ViewAsPdf object which, I am pretty sure, is not an object but a static method of the class Rotativa.
From the surrounding code I can read on your screenshot, I can assume the method ViewAsPdf returns a byte array, in which case the simplest solution would be to remove the new in front of it, which serves absolutely nothing in that case.
Please note that this answer is only based on assumptions due to the low amount of informations provided by your screenshot. You might want to publish your code in the question for us to better understand the context.
I am adding new table in database. Then for that when i am updating Edmx designer file become blank it's only contain:
"// Seeing this comment implies that the code generation for file
'E:\PrognoHealth\trunk\Development\PrognoHealth\PrognoHealth_MT\PHModel.edmx'
// failed. See the ErrorList for details."
And error list contain like
"Severity Code Description Project File Line Error CS0246 The type or
namespace name 'PrognoHealthEntities' could not be found (are you
missing a using directive or an assembly
reference?) PrognoHealth_MT E:\PrognoHealth\trunk\Development\PrognoHealth\PrognoHealth_MT\Partial\Address.cs 18
" error
Thanks in advance.
Please Check your EdmxFileName.context.cs file.
Check your EdmxFileName.context.cs file. Th class name must be "PrognoHealthEntities".Also check constructor name.
I am trying to get the dotnetopenauth oauth2 "windows live" example to work that is shown here:
https://github.com/DotNetOpenAuth/DotNetOpenAuth/tree/master/samples/OAuthClient
In the WindowsLive.aspx.cs page these two lines do not work:
windowsLiveClient.ProcessUserAuthorizationAsync
windowsLiveClient.PrepareRequestUserAuthorizationAsync
When I run the page it shows the error:
Compiler Error Message: CS1061: 'DotNetOpenAuth.ApplicationBlock.WindowsLiveClient' does
not contain a definition for 'ProcessUserAuthorizationAsync' and no extension method
'ProcessUserAuthorizationAsync' accepting a first argument of type
'DotNetOpenAuth.ApplicationBlock.WindowsLiveClient' could be found (are you missing a
using directive or an assembly reference?)
I am using the dotnetopenauth ultimate 4.3.1.13153 dll.
I also put these three files, that I got from the DotNetOpenAuth.ApplicationBlock folder, in my app_code folder:
IOAuth2Graph.cs
WindowsLiveClient.cs
WindowsLiveGraph.cs
I apologize for being a beginner. I have spent a few days trying a million different things and I can't get past this.