I'm getting this error in Visual Studio:
Error CS7003 Unexpected use of an unbound generic name MyProject C:\Users[myname]\documents\visual studio 2015\Projects....\Index.cshtml 1
The offending file is right here (line 1 error is the reference to the model declaration):
@model MyProject.Models.MyAccount.Details
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_PrimaryLayout.cshtml";
}
<!-- Page Content -->
<div class="container">
.... more page stuff follows from here
The model class is as follows:
namespace MyProject.Models.MyAccount
{
public class Details
{
public static Details Select(Company c)
{
Details model = new Details();
model.SomeProperty = "SomeValue";
return model;
}
public String SomeProperty { get; set; }
}
}
The weird thing is that cleans don't make it go away, rebuilds leave it there, and I build/debug just fine.
It took shutting down Visual Studio and restarting for the error to clear. Subsequent rebuilds do not produce the error.
Just cut the line @model
and save, then paste it again and save, it should be gone.
I made a mistake that took me quite a while to see. I created a generic method:
public static T MyMethod<T>() { ... }
By mistake, I wrote in my code
var something = MyMethod<>();
It compiled but at runtime it threw the error "unexpected use of an unbound generic name".
If ever you made the same mistake, you might try to search "<>" in your code...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With