I have a solution which has mixed .net framework.
Environment(in solution) : Website 3.5 Framwork
Class Library 2.0 Framwork
another Class Library 3.5 Framwork
I have added another class library with 3.5 framwork to use LINQ to SQL
add new item linq-to-sql and then added reference to website . once I have added this additional classLibrary with linq-to-sql my intellisense is lost. Even it doesn't recongnise txtBox in the markup. I can only include stadard data types like string , int etc..(If I force using Ctrl+spacebar).
Unfortunately there are probably quite a few reasons why this could happen. According to here there is something called "Low-Impact Intellisense" which can be toggled on and off by pressing Ctrl+Alt+Space.
Related
I'm using ASP.NET MVC Core RC-2. I have a web project targeting the full .NET framework. I also have a separate class library in the solution, also targeting the full framework.
In the class library, I have a controller, marked with a route attribute. I have referenced the class library from the web project. This assembly references the nuget package Microsoft.AspNetCore.Mvc v. 1.0.0-rc2-final.
It was my understanding that this external controller would be discovered automatically, e.g.
http://www.strathweb.com/2015/04/asp-net-mvc-6-discovers-controllers/
However this doesn't work for me- I browse to the URL of the route and I get a blank page and it doesn't hit my controller breakpoint.
Any ideas how to get this working?
Interestingly, it does seem to work for web projects targeting .NET Core Framework, referencing a class library also targeting .NET Core. But not for a web project targeting the full framework, referencing a standard .NET class library.
Note: this is MVC Core which is supposed to support this kind of scenario without any MVC<=4 routing overrides.
Still an issue in ASP.Net Core 1.0, not sure if it's by design now. Easiest solution is to do this in Startup.cs/ConfigureServices
services.AddMvc()
.AddApplicationPart(typeof(<class in external assembly>).Assembly)
.AddControllersAsServices();
AddApplicationPart explicitly includes the assembly in searches for controllers.
The call to AddControllersAsServices() will add all the discovered controllers into the services collection, and if you put a breakpoint after this line and inspect 'services', you will see in the collection all the controller types which have been found.
You might also want to check here: https://docs.asp.net/en/latest/migration/rc1-to-rtm.html#asp-net-5-mvc-compile-views as the discovery rules are now changed for controllers from RC1.
Also remember to use IActionResult instead of ActionResult!
I believe you are hitting the following known issue in RC2.
https://github.com/aspnet/Mvc/issues/4674 (workaround is mentioned in the bug)
This has been fixed since then but will only be available in next release (unless you are ok with using nightly builds)
Is it possible to use the 'DataTable' or 'DataSet' classes in ASP vNext Core 5.0?
When I try to use those classes, I am getting the error:
'The type or namespace name 'DataTable' could not be found'.
This question is a few months old but I see it coming up all the time so I'll post an answer.
As of beta 3, aspnetcore contains only a subset of the System.Data related members, which can be referenced in System.Data.SqlClient, and System.Data.Common. Among the more noticeable items missing from the data libraries are the following: DataTable, DataSet, IDbConnection, IDbCommand, IDbTransaction, and IDbDataParameter and IDataReader.
If you're looking to maintain some abstraction, you can reference the associated abstract classes like DbCommand, DbConnection, DbTransaction and DbDataReader. One thing to note, DbDataReader along with the SqlDbDataReader object no longer support the Close() method. Instead, you'll just call dispose.
I have not heard whether or not these members will be reintroduced in aspnetcore or not, but they don't appear to be in beta 4 either.
aspnetcore is subset of dnxcore and is considered deprecated, one should use dnxcore instead.
As for the DataTables and other related System.Data types, according to this issue they aren't going to include it soon, unfortunately.
Classes DataSet/DataTable/DataRow and everything related to them (DbCommandGenerator, DbDataAdapter etc) are not available in .NET Core 1.0 release (and in .NET Standards 1.3-1.6 specifications as well). This means that ADO.NET was reduced to minimalistic set of low-level interfaces and components (like IDbConnection, IDbCommand, IDbTransaction, DbProviderFactory). At this moment there are no confirmation that DataRow/DataTable will back in future .NET Core releases.
If you're looking for something between low-level .NET Core ADO interfaces and strongly-typed EF Core models - take a look to open-source NReco.Data library that provides alternative implementations for DbCommandGenerator and DbDataAdapter. I'm the author of this library, so you can ask me for details.
I'm new to entity framework. I've got EF 4.2, from NuGet. Now I'm hearing it would be good to get DbContext. I've got into the extension manager and tried finding it, but I see about 8 there. Which is the "righ" one? I don't know if this matters but I use both C# and VB.NET. Also, I don't know if this matters or not, but I'm using a data-first model, not a code-first or model-first models, for doing EF development.
On your EDMX design surface, right-click and pick Add Code-Generation Item:
Pick the ADO.NET DbContext Generator from the online gallery:
This adds two T4 template files (*.tt) in your solution explorer, and generates the DbContext and the entity classes for you:
And this is the resulting class derived from DbContext for your own project:
I'm actively developing desktop applications, local and network services, some classic ASP.NET, etc., so I'm used to static compilation and static code analysis. Now that I'm (finally) learning ASP.NET MVC 3.0 I'm seeing that many of the ASP.NET MVC experts and experienced developers are recommending using strongly-typed views in ASP.NET MVC 3.0 (where applicable).
I'm guessing that "strongly-typed" means writing #model=... at the top of a view's code. But in doing that I only get IntelliSense to work, no static code checking is taking place. I can write anything I want in the #model statement in cshtml and it would compile and run. Consequentially, Model.Anything also compiles. In fact, if I don't type #model I can dynamically use whatever model I want that has "compatible" properties and methods.
I'm used to "strongly-typed" meaning "won't compile", like LINQ to whatever just will not compile if you don't get the properties right. Is there any other purpose for #model other than IntelliSense and a run-time error, and why is it called strong-typed if it's in fact, not?
Strong typing, Meanings in computer literature
Views are compiled at runtime by default. You can modify your project file (csproj) to compile the views when the application builds by setting the following property:
<MvcBuildViews>true</MvcBuildViews>
Downside of this approach is that your buildtime will increase significantly. You should consider only setting this option to true for release builds.
You can edit your project file by unloading the project, right-click the project and choose Edit ProjectFile
It is possible to setup your project so that it includes views in your compilation. This would be where static typing is useful. Another place would be in runtime, if you try to pass in a model that does not match the expected model you will immediately get an exception. If you were to type views dynamically then you would not know your model was invalid until your view tried to access a property of the model and finds out it isn't there.
The second scenario is also a nightmare if you pass in the wrong model object but it happens to have the same named property as the expected model. Then you just get invalid data and debugging becomes hell.
model is new dynamic type in .net 4.0, so these types get resolved at runtime not at compilation time.
I'm getting used to the new IDE (it's vc# express), but the first contact is somewhat confusing. When I open the Add Reference dialog and switch to the .NET tab, a label above the assembly list states: "Filtered to:.NET Framework 4". And it's true - I can reference .NET 4.0 assemblies only plus things like XNA 3.1. However I can't see older assemblies i.e. Managed DirectX libs, which are obviously installed on my computer as there was no trouble with adding a ref to them in vc#08.
What is this? How to change the filter? The label is read-only. These sound like dull guy's questions, but I'm out of luck in finding an answer and there is no intuitive solution.
Thanks in advance.
Change your new application to target the .NET Framework 4 and not .NET Framework 4 Client
"When you create a new application, some projects target the .NET Framework 4 Client Profile by default."
http://msdn.microsoft.com/en-us/library/cc656912.aspx
"If you are targeting the .NET Framework 4 Client Profile, you cannot reference an assembly that is not in the .NET Framework 4 Client Profile. Instead you must target the .NET Framework 4. "
We've created a tool that will help you to achieve your goal. Muse VSReferences will allow you to add a Global Assembly Cache reference to the project from Add GAC Reference menu item.
Regards
s
How to change the filter?
Very simple - you must change the Target .NET Framework for your project, as whole. It's not pain :) just RMB on project name in Solution Explorer->Properties->Application tab->Target Framework(combobox). Select what you want. Change combobox == change filter in Add Reference dialog. ;)
I was having a similar problem until I noticed that the older .NET assemblies were actually in the list, there's just some really strange sorting going on. If you sort by assembly name, you should see them in the proper order.
Another possibility is to go into your project’s Properties page and change the Target Framework from 4.0 to your desired Framework. You will then need to reload you application. Now your Reference should be there. Once you have added the Reference you want, change back to 4.0 and again reload.
Hope this helps.
If, for instance, your project is Framework 4 and you want to reference say Microsoft.Deployment.WindowsInstaller (which is not in the filtered list of the .NET tab), then go to the Browse tab and enter the path to the reference item e.g. C:\Program Files\Windows Installer XML v3.5\SDK\Microsoft.Deployment.WindowsInstaller.dll