VS2010 converted project invalid reference - asp.net

Opening a .Net 2 project in VS2010 it converts the project without any issues BUT when I attempt to build it fails.
The reason is that in VS2005 a reference was added to System.Web.Extensions which is a .Net 3.5 assembly. Now VS2005 never complained at this and quite happily worked but VS2010 is far more strict and won't allow it.
I've tried changing the targeted framework to .Net 3.5 but I get another situation there where the web page is never displayed, it simply hangs not even getting to Applicatin_OnStart.
Any help either on adding the reference with .Net 2 as target framework (prefered option for time) or getting the .Net 3.5 version to work would be greatly appreciated.
[Edit]
Ok so maybe the reference was a read herring. One of my colleagues opened the project and did the conversion and once he changed the targetted framework to .Net 3.5 it all worked. The difference between our machines is that he's on 32 bit XP and I'm on 64 bit Windows 7. When I change the targetted version and try to run the program the build seems to stop at CppCodeProvider and hang.
[Edit]

Check your web.config file for the references to System.Web.Extensions. It could be there are duplicate entries or entries pointing to older versions.

Check if the project is just targeting the client profile. The following link could provide you additional information: System.Web.Extensions Assembly cannot be resolved

Related

.Net 1.1 upgrade to .Net 2 - Does it still use the .Net 1.1 framework

We have recently taken on support of a web application that was written many years ago and targeted v1.1 of the .net framework. It runs on Windows Server 2003/IIS 6 environment.
After looking at the configuration of the site in IIS the target framework is set to 2.0.
Given that extended support for .net 1.1 will cease in October of this year (http://support.microsoft.com/lifecycle/?p1=1249) I am trying to ascertain whether the site will still use any of the .net 1.1 framework assemblies given that the application is built and compiled in Visual Studio 2003.
I am assuming this is the case because although ASP.net 2 is set as the target framework
in IIS (and therefore the aspet_isapi.dll invoked is the .net 2 one etc) the assembly is a .net 1.1 assembly and will therefore still use the 1.1 framework. However, is this assumption actually true?
The website only has another year or so to live before being replaced by a new solution entirely so I would prefer not to upgrade it if possible and run the risks such changes bring with them.
However, we obviously can't run something on an unsupported version of the framework if any element of if that framework is actually being used.
Any thoughts would be appreciated.
Update:
It would seem that .net 1.1 is a core component of WS2k3 so you can't just uninstall it. I could have attempted to remove the ASP.net component but I don't think that would fully uninstall everything and given that the dev environment is shared I can't risk causing any issues right now.
However I have previously set everything up on my local machine (Windows 7/IIS 7), so I changed the application pool to point at .net 2 (it was already running in classic pipeline mode), uninstalled .net frameworks 1 and 1.1 and cleaned up the files left behind afterwards.
The result was that the site ran absolutely fine, which would suggest in an IIS 7 environment at least that I don't need to worry about upgrading given we are running under .net 2 within IIS.
It's not an ideal test as it isn't a mimick of our live environment. I'm going to post a question on MSDN and asp.net to see if any Microsoft folks can add anything more definitive. I will post back here with any updates.
Just because official support will end doesn't mean Microsoft will pull the plug and force an uninstall of .NET 1.1 via Windows Update. It only means that:
if a gaping hole in the framework's security is ever found, they'll not fix it;
There won't be redistributables for the next versions of Windows, and the next version of IIS won't run it.
So the application will still run in a year. If you leave the server alone, the application might run until the machine breaks of old age.
So my suggestion is relax, and focus more on the new solution.
I got the answer to this questions after reading this link (provided as an answer to this question on the ASP.net forums)
http://msdn.microsoft.com/en-us/library/ms994381.aspx
Under "Application Load Mechanisms and Possible Issues" it states:
By default, an application built using the .NET Framework will run using the version of the Framework it was built against if that version is installed on the computer
It then goes on to detail (for .net 1.1 and 2.0 at least) when a particular version of the framework is used.
Essentially, because our server has both 1.1 and 2.0 installed the application will still be using version 1.1. If 1.1 was not installed then it would run by default under 2.0, which explains why the web application still worked after I uninstalled .net 1.0 and 1.1 from my local machine.
Given that the live server is W2K3 and I can't remove .net 1.1, I will be rebuilding my application to target .net 4.0.

Visual Studio 2010 build with wrong framework

I'm working on Visual Studio Profesionnal 2010.
In my solution I've got 2 projects
The first is a web site with targeted .net runtime 2.0
the second is a dll with targeted .net runtime 2.0
I add the output of the second as assembly of the first.
I build and rebuild and clean my solution
result : Build succeeded
But when I launch the projet in my web-browser ( in debug or release ).
I've got the Server Error :
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded
Is there someone who had already the problem?
I think it can be a bug from Visual Studio 2010 but the hotline is very expensive
300€ the phone call.
More Information :
I opended my dll with reflector and saw that mscorlib is referenced 2 times
the first time Version = 2.0
and the second time version = 4.0
Open the .csproj file with text editor (e.g. Notepad) and see the references in there.
If there are references to frameworks higher than 2.0 remove them or change to 2.0 if possible, save and reload the project.
I am pretty sure that this means that you built with asp.net framework 3.5x, but your server only has 3.0x. Update the runtime on the server.
Your server can only support 3.0, Updating the server will resolve the issue..

ASP.net error message when using REST starter kit

I've written some code using the REST starter kit and it works fine on my development machine. However, when I upload it to our server the page gives me the following error message...
CS1684: Warning as Error: Reference to type 'System.Runtime.Serialization.Json.DataContractJsonSerializer' claims it is defined in 'c:\WINNT\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll', but it could not be found
I've removed code line by line and it appears that the following line of code is triggering the error...
HttpContent newOrganizationContent = HttpContentExtensions.CreateXmlSerializable(newOrganizationXml);
Really haven't got a clue how to fix it. I assumed it might be because it needs a newer version of the framework to run, but looking in IIS it says it's running version 2.0.50727 which I think is the lates version because it says that even when we're using framework 3.5
Very confused, any ideas?
Jon
At first I thought this was possibly because the server you're deploying to didn't have .NET Framework 3.5SP1 installed and only .NET 3.5RTM.
However, upon checking a .NET 3.5 RTM System.ServiceModel.Web.dll assembly I see that the System.Runtime.Serialization.Json.DataContractJsonSerializer is actually defined.
The compiler warning CS1684 suggests that there is a System.ServiceModel.Web.dll assembly in the server's GAC, but one that doesn't have the System.Runtime.Serialization.Json. DataContractJsonSerializer defined.
So things I would check:
Check that the deployment server is running at least .NET 3.5 RTM and that a beta or release candidate isn't in use or hasn't been left over.
In Visual Studio 2008 make sure you select a "Target Framework" of .NET 3.5 in the project properties.
One final check you could do to see if the problem lies with the server's framework install is to knock up a simple application to consume the DataContractJsonSerializer directly. There's an example on the MSDN documentation page for the class:
DataContractJsonSerializer Class (MSDN)
As a last resort, if the server is under your control then I'd uninstall .NET Framework 3.5 and then re-install from:
Microsoft .NET Framework 3.5 Service Pack 1 (Full Install)
Update:
As per your comments:
If you're running a beta of 3.5 then chances are that DataContractJsonSerializer isn't in the System.ServiceModel.Web.dll assembly.
I seem to remember back around the CTP, betas and release candidates there were late breaking changes in this area. I vaguely remember the DataContractJsonSerializer was one of these late additions/changes due to the increased popularity of JSON and community pressure. My memory is a bit vague but it rings a bell.
To replace the DLL you need to unregister the current version from the GAC then register the RTM one using the GACUTIL.exe tool. I wouldn't advise mixing RTM and beta bits, you're leaving yourself open to unpredictable behavour.

ASP.NET development server unwilling to upgrade to .NET 3.5

I had an ASP.NET 2.0 web project. Worked fine. I decided to upgrade the site to 3.5. The upgrade worked fine. I have added a IHttpHandler that required to include the following line in the web.config:
<add verb="GET,POST" path="MyOperation.asmx" type="MyClass"/>
This line in the web.config generates the following error: "Parser Error Message: Could not load type 'MyClass'."
This sounds like a typical spelling error in the class name. But it looks not, I checked it 1000 times. However, what is really strange that on the bottom of the "yellow-screen-of-death" page it says:
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
This is really strange. The project is set to 3.5. The only piece of code that use 3.5 features are the IHttpHandler implementation. All the rest of the web project are 2.0 compatible and works without problem if I exclude the line from the web.config.
Why is this?
[I did not try with IIS. I use ASP.NET development server.]
[EDIT] I have to apologize, it was stupid spelling issue as I expected in the first round. My IHttpHandler implementation was in a nested class and the proper class name is "OuterClass+NestedClass" vs OuterClass.NestedClass that I used in my config file. However, I thank to all who contributed because I learned new things on CLR versioning!
I think you need to use the fully qualified type name.
Like:
<add verb="GET,POST" path="MyOperation.asmx" type="Your.Namespace.MyClass, assembly.name"/>
and the error containing the version information of 2 is normall since the CLR hasn't changed for 3 and 3.5. the only changes were additional sepperate assemblies and syntactic suggar (like automated properties are a feature of the compiler not the runtime) ".net 4" will come with a new CLR.
The version is not an issue ( I think). .net 2 to 3.5 sp1 use the same run time. The newer ones are just new libraries and compilers. So from the asp.net point of view not much has changed.
ASP.NET 3.5 is really 2.0 with extra extensions. So, as long as the server has 3.5 installed, then the message that shows that you're pointing to the 2.0 framework confirms that you have it setup correctly.
The issue is likely what olle suggested, that you need the full class name, assembly name.
Also confirm that you have the dll in your /bin folder and that it's marked as an application if you're not working from the root of your site.
Go to the project properties. Choose the Application tab. Change the Target Framework to .Net Framework 3.5 if you haven't done that already.

ASP.NET 3.5 on Windows 2000

I am trying to get an ASP.NET 3.5 site to run on a Windows 2000 machine (not my idea!!!) but am having some problems. I have been working through copying required DLL files from C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5 into my app bin directory. This succesfully got me past the "assembly not found" errors.
However, I am now getting the following error.
Compiler executable file csc.exe cannot be found"
How can I fix this? It is primarily LINQ functionality I am looking to utilise.
You are going to have many issues as .NET 3.5 is not supported on Windows 2000 (see System Requirements).
You can try to install .NET Framework 3.5 manually. It relies on .NET 2.0 runtime + some extra stuff.
See Microsoft .NET Framework 3.5 in
Windows
2000
for install steps.
See also More details on installing
.NET 3.5 in Windows
2000
for explanations.
Install a Virtual Machine with a newer Windows in it ;-)
Many 3.5 sites will work just fine in 2.0, you just need to compile them that way. I would have whoever built the app switch to 2.0 targets and see how it goes. If that doesn't take, the VM option is probably the best way to fly.
Save yourself some time and pain, install on a platform that supports 3.5.
Trying to circumvent minimum requirements usually comes back to bite you in the end.
Just because you can doesn't always mean you should. :)
Unfamiliar with the environment, but...
More of the framework (including csc.exe) resides in %WINDIR%\Microsoft.NET\Framework\v3.5 (e.g. C:\WINNT\Microsoft.NET\Framework\v3.5) - are these files on your installation and the directory in your path?

Resources