This project is read-only.

Getting version errors!

Topics: ASP.NET 2.0
Oct 11, 2010 at 8:44 PM

I have finally been able to get this to run on my computer under IIS 7 or using my local host, but am still having a few issues. first and foremost is that ALL pages give me an error at the top (blue squiggly error):

Runtime error: the <compilation> element of the Web.config file does not have a 'targetFramework' attribute. therefore ASP.Net assumes that the Web application targets the .net Framework version 3.5 or earlier, but could not find files that are installed with the .Net Framework version 3.5 that it needs to compile. If you are compiling this Web application for version 3.5 or earlier of the .Net Framework, make sure that version 3.5 of the .Net Framework is installed. If you are compiling this Web application for version 4 or later of the .Net Framework, add the 'targetFramework' attribute to the <compilation> element of the Web.config file (for example, '<compilation targetFramework="4.0">'.)

If I add the targetFramework="4.0" it does get rid of the blue squiggly error, but then when I run it on my local host I am now getting this error:

Parser Error Message: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
Source Error:

Line 32:     </appSettings>
Line 33:     <system.web>
Line 34:         <compilation debug="false" targetFramework="4.0">
Line 35:             <assemblies>
Line 36:

Source File: C:\inetpub\wwwroot\TestBlog\web.config    Line: 34
Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434

I AM running version 4.0 on my computer (I upgraded to VS2010) but the Blog engine uses 2.0 framework. How do I fix this error? It is not as simple as just adding that targetFramework="4.0" to my Web.config file obviously, or I would not be getting the above error!

Here is my web.config file for the <compilation> section (you can see where I remmed out the targetFramework and the assemblies for version 4)

       <compilation debug="false"> <!--targetFramework="4.0"-->
                <!--<add assembly="System.Design, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                        <add assembly="System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                        <add assembly="System.Web.Extensions.Design, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

                <add assembly="System.Management, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                <add assembly="System.Configuration, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                <add assembly="System.Data, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                <add assembly="System, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                <add assembly="System.Drawing, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                <add assembly="System.Web, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                <add assembly="System.Xml, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />

Thanks for any help that is given.


Oct 11, 2010 at 9:41 PM

Looks like you using 4.0 on your local and than trying to run it on 3.5 or 2.0 on your host server. You need to verify .net version on your server and then setup Visual Studio with same version locally. BlogEngine currently uses .net 3.5 but can be compiled to 4.0 with minor change (adding reference to app services in core dll).

Oct 11, 2010 at 10:12 PM
Edited Oct 11, 2010 at 10:23 PM

This is not hosted at any site yet. I FIRST have to have it working on my local host. Yes, I am running .Net 4.0 on my local host - that is the version I have. The Web.config file that I show is the Web.config file that comes with the BlogEngine! That is my whole point! How do I change the Web.config file correctly to run .Net 4.0 for the BlogEngine? I tried doing what the error message said to do (as you can see by the code that I remmed out) but when I add that code and then try to run it on my local host, I get the Parser error. My local host should be running .Net 4.0 since that is the version of .Net that I have installed - right? Do I have to change something in my IIS? I though my running my project in my local host was running my IIS. I am confused now. My understanding is that I need to change the Web.config file in the BlogEngine to run .Net 4.0. but I tried that and got the above parser error...I must be missing something...

Thanks for your help.

ETA - I found the problem. When I remmed out the 2.0 code in the Web.config file (shown above), I missed a line of code referring to .Net 2.0, so it kept giving me that error. I went back and made sure to rem out ALL code referring to .Net 2.0 in the <add assembly > portion and now it works. Sheesh! I just hope this works when I do move it to my hosting service...I just hope they support .Net 4.0!

Oct 19, 2010 at 3:24 PM

I've finally gotten this all moved over to my hosting service and am again getting this error: Parser Error Message: Unrecognized attribute 'targetFramework' I uploaded the exact web.config file I was using that I had removed all the references to .Net 2.0 from, but it looks like I may have missed something. I actually think though that it may be due to the virtual directory on my hosting service not being set to an application - that gave me loads of trouble on my local host. Has anyone gotten this error with your hosting service, and how did you fix it? Any help would be greatly appreciated. TIA!

Oct 19, 2010 at 5:51 PM

It sounds like the hosting service is running .NET 2.0 or .NET 3.5 -- not .NET 4.0.  The "targetFramework" attribute is new in .NET 4.0.  So if it's not recognized (which is what the error message says), that probably means the hosting site is an older version of .NET.

I would try uploading the web.config file that comes with BE (overwrite the one that is there now).  This one is setup to work with .NET 2.0, and works with .NET 3.5 too.

Oct 19, 2010 at 7:22 PM

I know, thanks.  It irritates the hell out of me! I just signed up with Arvixe, and they do support .Net 4.0. but I can't find where I can go to select the correct application pool 4.0 for my application on their control panel! ARGH! (banging head!) I had this working absolutely perfectly on my local host. Seems as though it's Murphy's Law on this website! Thanks for your help. If I can't get them to answer my requests for assistance, I'll have to change the web.config back to 2.0 - but I developed the whole thing (my pages) using .Net 4.0 - so it's going to be an issue either way. (Sigh) Once again, thanks very much for the help.