ASP.NET Web API on .net 4.0 - asp.net

I have ASP.NET web api project created on .NET v 4.5
I later i was decided to change framework to 4.0
After changing i got an error. VS can not regognize types and namespaces althougt all required librariesare referenced.
It does not happen to newly creted test API project.

Try to check that the dlls you are referencing are for version 4.0 and not 4.5, could be you are still referencing 4.5 libraries which won't work with .net 4.

Related

Can I upgrade my .net 4.8 webforms webapp to .net 5.0?

I have a medium-sized Web Application project on Framework 4.8. It has Webforms and MVC (and webapi) in it. I am confused by the recent 5.0 announcements that seem to indicate that everything should now be 5.0. After downloading the new SDK, and Visual Studio 16.8 preview4, I am still not able to change the target framework of my main webapp project in its settings. Am I missing a step? Can I upgrade my .net 4.8 app to 5.0?
Web Forms is not included in .NET 5. You will have to eliminate Web Forms from your application if you want to upgrade to .NET 5.
Rich Lander (Program Manager on the .NET team at Microsoft) explicitly pointed this out on Twitter.

.NET Core and .NET Framework 4.7 edit project option not available

When I create a .NET Core 2.0 Project I have to select both .NET Core version (2.0) and a .NET Framework version (4.7). But when I edit the project, I cannot change the .NET Framework version. Why is that? I am trying to use the function app.UseRewriter(options); and it is unavailable so I am theorizing that I have the wrong .NET Framework
I guess I just needed this package
Install-Package Microsoft.AspNetCore.Rewrite -Version 2.0.1
Yes, that's a confusing GUI. That got me mad as well (like some other stuff in Visual Studio if you are used to Jetbrains-IDEs).
You have chosen an ASP.NET Core Web Application as project type. So the only target frameworks that are being offered to you are .NET Core 1.0, 1.1 and 2.0 (in case you have installed 2.0, like you did).
Chose Web -> ASP.NET Web Application (.NET Framework) to get what you want.

Will the MVC 2.0 assemblies compiled against 3.5 and 4.0 live side-by-side in the GAC?

We are upgrading some of our VS2008 solutions to VS2010, but we are not yet prepared to go to .NET 4.0 on all our projects. At the same time, we are looking at a move from MVC 1.0 to 2.0. I know that there are MVC 2.0 assemblies/code compiled against both the 3.5 and 4.0 .NET Frameworks, but will these two MVC versions live side-by-side in the GAC of a single machine? Meaning, can I deploy both an MVC 2/.NET 3.5 site and also an MVC 2/.NET 4 site on the same server, provided that the server has both frameworks installed and I have run both the "MVC 2 2008" and "MVC 2 2010" installers?
There is only a single System.Web.Mvc.dll v2 assembly, and it is compiled against .NET 3.5. (Though it will also run correctly on .NET 4.) The end result is that if you have MVC v2 GACed, it will automatically operate correctly on both ASP.NET 3.5 and ASP.NET 4 sites.
The only thing you need to worry about is if you are putting your own assemblies in the gac, and you have the same dll in both .net 4 and 3.5. If so just use different version numbers and different snk.

ASP.NET 2.0 Website uses .NET framework 3.0 DLL

We are developing ASP.NET site in VS.NET 2005. This site is will be hosted on server which has .NET 3.0 installed and in IIS, ASP.NET 2.0 would be selected under ASP.NET tab.
We would use external DLL which is being developed in VS.NET 2008 with .NET 3.0 as taraget framework. Here they are using .NET 3.0 / C# 3.0 features such as Lamda expressions.
Now, the question is,
1) If we were not using this external DLL (.NET 3.0 as taraget framework), which .NET framework version it would use for this site? Since in this case only .NET 2.0 DLLs are referenced, I think it should use 2.0 framework only.
2) In current case where we are using this external DLL (.NET 3.0 as taraget framework), will it load both framework in memory for this website or just highest version i.e. .NET framework 3.0?
3) Are there any side effects in this case because the application (website) DLL would ask loader to load .NET framework 2.0 and one of the extrenal DLL, the main application requires is in .NET 3.0. Is is possible that .NET 2.0 will be loaded first for the application but when application references external DLL, .NET 3.0 framework will be loaded?
4) Is there any difference if
the external DLL developed in .NET 3.0 as taraget framework was refereced as "Add Reference" using VS.NET 2005
the external DLL developed in .NET 3.0 as taraget framework was just copied into bin folder of application (website)
5) If it depends on what features are used in .NET 3.0 framework, please provide details in both cases; when those features used and those features are not used.
.Net 3.0 is an extension of .Net 2.0. There is no "replacement" of the framework DLLs when you use .Net 3.0 because it is composed of the same libraries, plus some additional DLLs for the added functionality. Think of the extra .Net 3.0 DLLs as additional, external functionality that is only loaded as needed.

Can you make a site with ASP.NET MVC Framework using .NET 2.0?

Is it possible to make a site with ASP.NET MVC Framework using .NET 2.0? I am limited to using .NET 2.0 (we use VS 2008, but we have to use the 2.0 Framework) and I really want to try out the MVC Framework.
Scott Hanselman described a way to make it work, with some caveats, in his blog:
Deploying ASP.NET MVC on ASP.NET 2.0
It can be done using Visual Studio 2008, but it can cause headaches...
Create an ASP.NET MVC Web Application
Set Project Target Framework to 2.0
in Project Properties
Add a references to System.Web.MVC (click through warning messages)
Add any additional references you may need (System.Web.Routing, System.Web.Abstractions) again clicking through any warning messages
Start coding!
Not everything you try will work, if you see errors like this on deployment it means that whatever you are doing isn't supported by the 2.0 framework...
"The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?)"
Configure your IIS to support MVC Routes and extensions
Copy "C:\windows\assembly\GAC_MSIL\System.Core" from the .NET 3.5 development framework to the /bin folder of the IIS Server running .NET 2.0 SP1.
Much of this can be found in a lot more detail on Scott Hanselman's blog

Resources