My MVC project has used T4MVC for scaffolding working fine for years. I made a change to the parameter inputs for one of my controller methods and for some reason when I ran "Run Custom Tool" to pick up the changes, it instead over wrote the T4MVC.cs file with the text "ErrorGeneratingOutput".
I tried backing out the changes with no effect. I also cleaned and tried rebuilding the project multiple times but now there is just no classes under T4MVC.tt and it still fails the same way when trying to regenerate everything.
When I attempt to debug the template ("Debug T4 Template") it over writes T4MVC.cs file with "ErrorDebuggingTemplate" instead.
I also tried updating T4MVC to the latest version on nuget (3.17.4) but that didn't change the behavior at all.
Until this is fixed I can't push any changes as the project now reports thousands of errors (most missing assembly references) so would really appreciate any help getting this resolved. Thanks.
I was having a similar issue accompanied by build errors, such as "Invalid token 'this' in class, struct, or interface member declaration". Other devs on my team were not having the problem.
We were on version 4.2.1 so I upgraded to 4.2.4 and the problem went away. 4.2.4 ran and changed two action methods to be virtual (I'd forgotten to do that, so maybe that was causing the issue).
This is a little late, but maybe someone else can benefit from it.
Related
I started encountering this issue about 3 days ago after an update that I randomly clicked on when I was in Visual Studio Code. Whenever I try to access HttpRequest.Query from the Microsoft.AspNetCore.Http namespace, I get an the following error message: "Entry Point was not found".
I have not been unable to fix this and this has interrupted my ability to work. I've talked this over with my teammates, and they are not encountering this issue at all.
I've tried pretty much everything I could google and think of.
Auto Generating Bindings
Deleted and re installed every Nuget Package at C:\Users{username}.nuget\packages
Deleting and reinstalling everything about Visual Studio and Visual Studio Code
Using the most recent versions of Microsoft.NET.Sdk.Functions
Deleting the bin and obj folders of my project
Removing unused references in my project
At this point, I'm not even sure what's really wrong any more. I found a post with my EXACT SAME issue, but the way the person fixed it did not apply to me:
Azure Functions .NetCore 3.0 Request.Query throwing "Entry point not found" error
Some Info- may or may not be useful.
When I go through the code step by step in the debugger, HttpRequest.Query shows up properly with all of the keys. I'm wondering if there is some kind of name conflict between HttpRequest object from Microsoft.AspNetCore.Http vs System.Web
If I set my project to use the most recent version of Microsoft.NET.Sdk.Functions, I get a new error instead of an entry point error, I get this instead:
I'm using Visual studio Code.
Can anyone assist? I'd be happy to provide any information needed!
I gave up. I spent about 3 days trying to solve this and this was affecting my ability to work. I just had my entire laptop reformatted and that "fixed" the issue. I tried pretty much everything I could find and nothing worked and I couldn't wait any more. Best of luck to anyone who encounters this!
I'm trying to run a .NET MVC application on my local computer that I got from GitHub.
When I hit run on Visual Studio, everything complies and a new browser window opens with the error:
CS1980: Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute'
The compiler section in the same window, shows the following error:
I've checked on google and this seems to be the same error.
This guy was using a dynamic type himself, on the other hand I'm not using any dynamic type, this is being auto generated by .NET's compiler, and I'm using .net 4.5 which should has support for dynamics.
I tried to apply the same solution (Changing all System.Core references to 4.0)
but the thing is that all of them are version 4.0 already.
Do you have any idea how could I resolve this?
I had a similar error on a project I was trying to migrate. Try re-targeting the framework of the project back a version or two, and once you find a target version where you do not get the error, re-target back to the version you originally had trouble with.
I was getting the same error on a website project targeted for 4.6.2 that was referencing some older libraries, re-targeted it back to 4.5.1 and that resolved the error. I immediately re-targeted back to 4.6.2 and did not encounter the error again.
I had this same issue, but none of the answers here solved it, but did point me in the right direction. I think I didn't update the .NET version on my machine to the newer one. After installing it, I rolled back the targeted framework (as was suggested), retargeted the newer framework, and did a few extra things also:
Reinstalled ALL packages by running this in the package manager:
update-package -reinstall
I also compared my project to one that was working for 4.5 and did this:
Opened my project file and removed all "BCL" related elements.
Uninstalled all "BCL" packages in the NuGet package manager for the project (guess it's not needed moving to 4.5+...?)
Removed an old package version of System.Net.Http, which did not get updated for some reason (see web.config - versions should show oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0").
Have to restart VS.
Rebuild solution.
Error is now gone. ;)
One other thing I did to resolve some other errors was to clear the component cache by deleting all files in here:
C:\Users\{USERNAME}\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache\
[rant] Wasted a whole day with all this. Thanks to MS for stealing one more day of my life fixing senseless issues that should never be. Every time I upgrade I always get a wonderful surprise, and a lovely game of fix the red herring. Would it not hurt to detect these conflicts for those upgrading old projects? Perhaps better error traces when things go wrong? I doubt it would be that difficult. Perhaps even something like AsmSpy, but more advanced, built in to VS? [/rant]
Saw this in VS 2019. I excluded and re-included the problematic file (in my case _Layout.cshtml) and that fixed the problem.
I got this error suddenly a couple days after updating to VS2015.3 using 'traditional' MVC app (not new .NET Core / vNext app).
Turns out this error can be a complete red herring.
Make sure:
You haven't got any other errors at all
You've checked the output window for any errors that don't show in the 'Output' window.
Make sure you don't have any conflicting references
In my case I had a typescript error that was causing an error and for some reason triggering this weird 'red herring' dynamic error too.
My fix was to go into the .csproj file and update the typescript tools version to 1.8 (need to unload project and edit by hand). As I said this is unrelated to the error, but I mention the specifics because someone else may end up with this same problem.
I believe that 1.7 didn't accept 'None' for the typescript module system whereas 1.8 does, hence the error.
Adding a reference to System.Dynamic.Runtime did it for me.
I hesitate to write this as an answer, but for me the error appeared in a .cshtml file. I closed the page, rebuilt, and the error vanished. Always best to try the simple things first.
I had the same error, there were just 2 unused tables of my databaseset that I had to delete. I wonder why it worked when I manually change sth in an auto-generated code work but after deleting, it worked.
So be aware that such inconsistencies can also cause this error.
My solution was to correct the version of MVC in web.config under Views folder. E.g. the project referenced MVC assembly version 5.2.2.0 but in the Views/web.config file was version 5.2.4.0 (see image).
Image
Tried a few other answers with no luck, but the overall consensus appears to be that this some sort of issue with cached build artifacts or compiler state or something. Here's what worked for me:
Delete the problem .cshtml file, watch error disappear
Open source control and revert the deletion
This error will come because of the different versions of your Sitecore.Web.Mvc.Dll in solution reference folder(Project name->References->Sitecore.Web.Mvc->right click and check properties) and the version of Sitecore.Web.Mvc.Dll in Web.Config in views Folder.
For solving this error you have to make sure that the version of Sitecore.Web.Mvc.Dll is same in both folders.
Thanx.
For my case, I fixed to run the command line "update-package -reinstall" on the Package Manager Controler.
My problem was in the _Layout.cshtml.
None of the solutions above did the trick for me. I am using VS2017 for this project, upgraded an ran into the same message.
I had commented out a 2 lines in 1 comment #* *#
My solution was to comment out each line separately. What a mystery!
A few hours lost on this.
I have a weird error showing up in my project when it is open in the VS2012 IDE. Everywhere where I make use of another referenced project it suddenly says "Type or Namespace name could not be found". And by "says", I mean it has the text underlined in red with the error when I hover over it. The intellisense doesn't work for that code. BUT (and here's the weird part), the errors do not show up in the error console and the project builds and runs fine.
I can even debug and step through the code and it works perfectly fine. So at runtime the project is referenced fine but at design time the IDE can't find it. This worked for the past 2 weeks, and only then suddenly went a little bonkers. It's really annoying because I am rubbish at coding without intellisense!
Has anybody ever seen anything like this or have any suggestions?
I had this. I referenced assemblies whose "Target Framework" were set to ".Net Framework 4" in the "Application" secion of the projects properties. I changed this to ".Net Framework 4.5" not just in the referenced assembly's project but also the project I was building and it worked. Give this a try.
I have found this is a known problem with VS2012. Check to see how you are building, 64 bit or 32 bit. It won't work with 64 bit but it will with 32 bit. It will say things are missing and design will not work, however the program will run fine. I have heard the new VS update that hasn't been released yet will fix it.
Manually delete all the references to the libraries of the other projects and re-add. Intellisense rebuilds whatever it needs at that point and doing this has helped me in the past.
Another source of this problem is a solution with multiple projects containing code for the same namespace. The compiler can handle this. Intellisense won’t.
Related to a couple other answers here, I had a "Data" project using a "Data" namespace. Built fine, but just started recently showing errors from intellisense (even though it continued building fine.) (VS 2015.)
I fixed this by changing my "Data" project and namespace to "MyCompany.Data".
Oddly, the problem didn't seem to show up until recently, but making the change did fix it. Presumably there was a conflict in namespace with another project or reference, which can build fine, but intellisense can't handle.
You can change this in the Application tab of Project properties. You can also open up an EDMX diagram, right click, choose model browser, choose the second collapsable item in the model browser tab, hit properties, and there you'll find the Namespace option for generated Entity Framework entities and contexts. (Similiarly, if you modify an Entity Framework Model's namespace, you might also need to change the related connection to match [in Web.Config for ASP.Net and MVC.])
Make sure that there is no class with the name same as Project default namespace.
make sure that you don't reference .net framework 4.5 projects in .net 4 projects!
Examine your .proj files in a text editor and make sure the paths to your references are correct.
This can also happen if you set the Build Action to "None" on the referenced file and forget about it.
I had the same problem, where it would build and run fine, it just would always show that error and I couldn't use intellisense with the class.
I actually used the automatic method of creating the class in a new file to resolve the issue, then just copied the code over from the real class. I deleted the old file, renamed the new file, and now it works.
Since installing the recent tools update for MVC3 adding a controller through the "Add Controller" context menu is often failing with the error:
Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
Or simimlar (sometimes another dependency, such as "Mono.Addins" etc).
The references it complains about aren't needed by the project directly, but are referenced by other references this project has. The project builds find without the references, but Add Controller fails.
Adding the reference mentioned in the error doesn't fix this either. Even after adding a reference to Newtonsoft.Json (with the correct version and token) the error remains.
I suspect this due to the reflection the Add Controller dialog does to provide a list of model types that can be used, but I can't understand why it still errors even after adding the requested reference.
The "Add View" dialog is slightly better but still fails. The dialog opens, but when you tick "Create a strongly-typed view" the dialog immediately closes.
At the moment my work around is to manually add Controllers, and to add non-strongly types views and edit them by hand afterwards, but this is becoming really frustrating - especially since I can't take advantage of our customer T4 templates for scaffolding views and controllers.
Anyone else experienced this since the update and know how to fix it?
I had the same problem with protobuf.
It means that one of the projects you reference has a dependency on Newtonsoft.Json, my guess is that it's via attributes.
When VS tries to reflect on your assemblies' type to offer you model classes in the dialog (Add Controller / Add View) it can't find Newtonsoft.Json to figure out what it's reflecting, Adding a reference to Newtonsoft.Json to your MVC project should fix that.
Drop all of your dependencies and update their dlls to the version you want to use again. This fixed it for us, was happening to a couple of different libraries, not just one.
I finally solved it. I guess the problem can reside in different places. In my case, I had added models to my domain, but I had forgotten to add contexts for these new models; things like
public DbSet<Region> Regions { get; set; }
I had no error at compile time, and I was not using these models yes in the solution, so there was no error at run time either. It is a bit by chance that I found this. Another thing I have to mention is that I rebooted my machine in the meantime. I don't know if this affected things also, but I rather think the problem was due to the missing contexts.
This has nothing to do with the tools update. I had a similar problem and fixed it by rebuilding my whole dependency tree, starting from the "leaves" (i.e. projects that have no dependecies). There was a similar question already, my answer to it is here: https://stackoverflow.com/a/6627505/342838.
Thanks, this helped me. I had recently added a library called OAuth2.MVC to my MVC4 Web Api project, and then this error started occurring. Oauth2.MVC had a dependency on Newtonsoft.Json version 3.5.0.0, and my project already had version 4.5.0.0. I went back to the OAuth2.MVC project (it's open-source) and upgraded the version of Newtonsoft.Json there to 4.5.0.0, rebuilt it, and then re-imported the reference into my MVC4 Web Api project, and I could then add a controller without the error.
I've just come across a pretty strange problem with VS2010 and Script#, which most of the time I am able to re-create.
In my simple scenario I have 2 projects in my solution; a standard Asp.Net MVC2 Web Application, and a Script# jQuery Class Library. I created a static class (attributed with [Imported]) with a static method on it, the intention being that I can map this class in code to an external Javascript library, as described in the documentation.
However, it seems that whenever I decorate such a class with [IgnoreNamespace] to achieve this goal, the project stops successfully compiling but doesn't give me any feedback as to why it's failing (no errors in the error window, for example). It's not easy to get rid of either, as Visual Studio seems to get into a permanent state of not build failure; removing the classes and project files doesn't solve it, nor restarting visual studio. The only way I can get VS to build the project successfully is to delete the project entirely, create a new one then add the files back in, which is annoying to say the least.
With a verbose build output setting, I get the following:
Target "AfterCompile" in file "C:\Program Files (x86)\ScriptSharp\v1.0\ScriptSharp.targets" from project "e:\project\local\ScriptSharpDemo\Scripts\Scripts.csproj" (target "Compile" depends on it):
Task "ScriptCompilerTask"
Done executing task "ScriptCompilerTask" -- FAILED.
Done building target "AfterCompile" in project "Scripts.csproj" -- FAILED.
.. which doesn't tell me whole lot.
There have been a couple of times where I have managed to create this type of class and then successfully build, but mostly I can reproduce this problem pretty reliably.
At this point I'm inclined to think that the bug lies with Script#, but would just like to have that confirmed, and to find a possible work around if there is one.
Just in case anyone is having a similar issue, I've found the cause of the problem.
When adding a class using this method, or copying in a file from another project for use within Script#, this causes a reference to System.dll to be added to the project. This (understandably) causes the project to stop compiling without error.
It would be nice to have a warning about this or for Script# to somehow detect when this situation occurs and/or create a new template for when I use 'Add class' or import a file, but it is just a convenience issue and at least now I can painlessly get my project compiling again just by removing this reference.
When trying to make my project build again, I came across the following, possible solutions:
The "Home\HomePage.cs" and "Shared\Utility.cs" must not be deleted and remain where they wre initially created
The "Home\HomePage.cs" and "Shared\Utility.cs" must be the last entries in the "*.csproj"-file. After them, no "Compile" tag should follow
Problematic calls to "Script.Literal" might cause silent fails - especially be careful when having parameters (like Script.Literal("{0}.doFoo()", variable))
The same seems to be true for "String.Format" when the format parameters are invalid
Namespaces and folders seem to cause many problems, putting all classes into the same namespace and all classes into the same folder might help
I tried all of the suggestions that have been given here, but continued to see the issue. Eventually, I determined that the cause in my situation was that I had added an [IntrinsicProperty] attribute to one of my properties. Removing it solved the issue. Don't ask me why this was causing a problem, but I thought I would share this solution in case others run into it.