Make T4MVC work with ASP.NET 5 - asp.net

According to the latest comments in this thread, .tt templates will now after all be supported in ASP.NET 5 starting with Visual Studio Update 1.
Which IMHO would be great because after using T4MVC for years, I certainly don't wanna go back to using magic strings for route/view names (error prone and not refactoring-friendly).
However, I can't quite get it to work with ASP.NET 5 RC and Visual Studio Professional 2015 Update 1.
Here's what I've tried:
Adding the T4MVC NuGet (3.16.5) to a blank ASP.NET 5 solution: nope, CoreCLR complains and no .tt files are added to project:
Error NU1002 The dependency T4MVCExtensions 3.16.5 in project
WebApplication1 does not support framework DNXCore,Version=v5.0.
Add the NuGet to a classic ASP.NET 4.6 solution and manually copy over T4MVC.tt, T4MVC.tt.hooks.t4 and T4MVC.tt.settings.xml to the ASP.NET 5 solution: Visual Studio indeed offers to "Run Custom Tool" on the .tt file....
... but running the transformation throws a NullReferenceException:
Severity Code Description Project File Line Suppression State
Error Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.VisualStudio.TextTemplating3FE65EE761BB32C4AE5AEEB1949A6FC143551E0A56C74E6B36511A416E2DE40FB92F7CB1BC6FC7A97FF5B622AE39377BBFB9463480555898ADB8DD6D286C533D.GeneratedTextTransformation.GetProjectItem(ProjectItems items, String subPath) in c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt:line 1398
at Microsoft.VisualStudio.TextTemplating3FE65EE761BB32C4AE5AEEB1949A6FC143551E0A56C74E6B36511A416E2DE40FB92F7CB1BC6FC7A97FF5B622AE39377BBFB9463480555898ADB8DD6D286C533D.GeneratedTextTransformation.GetProjectItem(Project project, String name) in c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt:line 1378
at Microsoft.VisualStudio.TextTemplating3FE65EE761BB32C4AE5AEEB1949A6FC143551E0A56C74E6B36511A416E2DE40FB92F7CB1BC6FC7A97FF5B622AE39377BBFB9463480555898ADB8DD6D286C533D.GeneratedTextTransformation.ProcessAreas(Project project) in c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt:line 600
at Microsoft.VisualStudio.TextTemplating3FE65EE761BB32C4AE5AEEB1949A6FC143551E0A56C74E6B36511A416E2DE40FB92F7CB1BC6FC7A97FF5B622AE39377BBFB9463480555898ADB8DD6D286C533D.GeneratedTextTransformation.PrepareDataToRender(TextTransformation tt) in c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt:line 557
at Microsoft.VisualStudio.TextTemplating3FE65EE761BB32C4AE5AEEB1949A6FC143551E0A56C74E6B36511A416E2DE40FB92F7CB1BC6FC7A97FF5B622AE39377BBFB9463480555898ADB8DD6D286C533D.GeneratedTextTransformation.TransformText() in c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt:line 40 WebApplication3 c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt 1398
Any other suggestions?
See also this related question about alternatives to T4MVC in ASP.NET 5.

As David Ebbo (hey!) pointed out, R4MVC - a side project was started a long time ago, but was stalled due to (at the time) breaking changes in the Roslyn compiler.
Luckily, the project was revived, and R4MVC has just released it's first alpha build, with more changes coming soon.
While the project works somewhat differently, and isn't using t4 templates, the end result is the same, and we're working to achieve feature parity with T4MVC in the near future.

At this point, T4MVC is not designed to run on ASP.NET 5 projects, so I'm not surprised that it doesn't work.
A while back, a separate R4MVC project was started, using a Roslyn based approach. However, this was done at a time when there was no T4 support with ASP.NET 5, and that has now been revisited.
So it's possible that there is hope to get T4MVC running on there, but someone would need to invest the time to see how far it is from working.
I just took a tiny step and fixed the null ref that you hit (not yet released, you'll need to hand fix). However, I then hit a condition where it seems to hand altogether.
Anyway, this is not the place to fully investigate all issues, but if someone wants to take that on, we can discuss on https://github.com/T4MVC/T4MVC.

Related

.NET Core - Project compiles and run, reSharper shows lots of errors on "FileStream" and "MemoryStream" objects

I have a .NET Core project which compiles and runs without errors.
However, ReSharper (version 2017.1.2) throws up a number of errors throughout the project, mostly related to stream objects.
For example:
Cannot convert source type 'System.IO.MemoryStream' to target type 'System.IO.Stream'
and when reading a stream
Module 'System.Private.CoreLib, Version=4.0.0.0 {snip}' should be referenced
I think it's related to the latter error, however as everything runs it's just frustrating that I can't track it down.
Or should I just get ReSharper to ignore these errors?
It's a known issue in ReSharper 2017.1.3 https://youtrack.jetbrains.com/issue/RSRP-464676.

Enity Data source wizard only compatiible with framework 5

I'm going to try and connect to my EF Data Model for the first time and when I do I pull this error message:
This version of the Entity Data Source wizard is only compatible with Entity Framework 5. If you’re not using Entity Framework 5 you can configure the control by editing the markup on the page. The page editor has IntelliSense support for ASP.NET controls. If you’re using Entity Framework 6 you should also be using the EF6-compatible version of the Entity Data Source control, available as the Microsoft.AspNetEntityDataSource package in NuGet.
Now this threw me a bit because I thought that I had all my updates in place but I went back to NuGet and double checked and did a full refresh of anything I could to make sure that VS knew it was there an verified everything was in place and on 6 as intended. Then I noted in the update tab there was three items there that I could put up (Bootstrap 4.0.0-alpha2, Microsoft.AspNet.Idntity.EntityFramwork v3.0.0-rc1-final, and Microsoft.NetCompliers v1.2.0-rc). This I attempted but that bombs out with the error:
Failed to add reference to 'System.Runtime'. Please make sure that it is in the Global Assembly Cache.
I'm a bit stumped here... no path forward no path backward that I can see.

Unable to load the specified metadata resource still comes

Yes, I know, this is the n'th question around this issue. I tried a lot of mentioned ~solutions, but none of them worked for me.
Windows 8.1, Visual Studio 2012, .NET 4.5.51641, Entity Framework 6.1.1
My struggle is to configure a well structured ASP.NET project, separate the different entities. I need more entities and in separate folders because of some overlaps among generated class names.
Therefore I've created a DAL folder and the first one, the Production. My model is quite simple, during the mode creation I've created the ProductionEntities entity connection string as it seems bellow:
Here is the ProductionModel.edmx and its properties:
I checked the assembly with reflector, all the resources are correct:
After that I've created a webpage and an EntityDataSource within it. If I select the ProductionEntities for Named Connection, I get above mentioned error message.
Have anybody some fresh idea for this? Thanks in advance!
I've got the solution!
After creating the entity model, it is MANDATORY to compile the project! After compilation the VS is going to recognize the entitydatasource wizard works fine...

.Net different IL but same output. Why?

I have 2 dlls ('original' and 'new') and for one method the IL is very different inside these 2 dlls (not talking about the nop alone but lot of differences). But when I decompile these two dlls then the C# produced is exactly same for these two.
Why it is happening? Is it OK and valid scenario? Can I assume the functionality is same based on decompiled C# code (though the IL are lot different)?
Other Info:
Visual Studio 2008 (3.5).
Method contains long chain of switch...case statements.
I can not modify the 'original' dll (c# code) but I can modify the C# code of 'new' dll to regenerate the dll and compare again.
IL sample is very big otherwise I could have pasted here.
I am unable to find a way to make the IL of 'new' dll (by modifying the C# code) exact same as 'original' dll. Any suggestion to achieve this?

rdsserver.datafactory converttostring failure

I have a classic ASP application written many years ago that I'm trying to fix.
The following lines recently stopped working after w7 sp1 was applied.
set address = Server.CreateObject("ADOR.Recordset")
count = lo_connection.GetRecordset(sql,address,false, error)
Set RDF2 = Server.CreateObject("RDSServer.DataFactory")
Set teststring = RDF2.ConvertToString(address)
It fails on the last line there saying "Microsoft VBScript runtime error: Class doesn't support Automation"
A bit of searching found several articles like this one
http://blogs.technet.com/b/asiasupp/archive/2011/03/14/changes-in-mdac-adodb-com-components-in-windows-7-service-pack-1.aspx
that described the problem exactly. Where I am failing is that none of the suggested fixes seems to fix the problem. Any suggestions?
The solutions described in the link are not relevant here, since ASP is not early-bound - it uses OLE Automation. It might be worth re-registering the component which creates RDSServer.DataFactory objects (which is C:\Program Files\Common Files\system\msadc\msadcf.dll on my machines).
I looked up this object, and I found this Microsoft web page:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms681447(v=vs.85).aspx
"This feature will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Applications that use RDS should migrate to WCF Data Service."
Doesn't sound too good.

Resources