Javascript errors after upgrading to .NET 4.0 - asp.net

I have inherited a working VB.NET 2.0 web app that has several User Controls with GridViews inside Update Panels. After running the VS 2010 Upgrade Wizard, the app runs fine in the debugger except for a couple of these Gridviews. In these, update and delete work but adding a new item causes the following javascript error when Save is clicked (calling DoPostBackWithOptions):
Microsoft jscript runtime error
Sys.WebForms.PageRequestManagerServerErrorException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
My theory is that the code is fine (I haven't touched it) and that there is some sort of configuration issue causing this. I have looked through SO and elsewhere and have tweaked my web config and updated the Ajax toolkit assembly. I got nowhere stepping thru the ScriptResource.axd javascript throwing the error. Any suggestions?
Update
The app works fine if I upgrade it to .NET 3.5 using the VS 2008 wizard. However, if I then upgrade that to 4.0 with VS 2010 the problem resurfaces.

Have you tried setting the controlRenderingCompatibilityVersion? The upgrade process should have included it for you, but it might be the cause of your heartache. It's in the <pages... tag of your web.config file...

This is only a workaround not a fix. But I figured I'd add it to help anyone else that might have a similar issue.
What I have figured out is that the project upgrades to .NET 3.5 just fine but that going 4.0 breaks it. I am not sure if the framework breaks it or the upgrade wizard does.
So the successful path for me has been:
Open in VS 2008 and run the upgrade
wizard to upgrade to 3.5.
Open the project again in VS 2010
and run the upgrade wizard but opt
to leave it on the 3.5 framework.
At this point the project behaves fine and I can used VS 2010 to make my updates.

Related

Migrate old VB.NET project from VS2013 to VS2017

I have a huge enterprise asp.net application that perfectly builds and runs on servers. We've been using Visual Studio 2013 in our workflow. Now we want to migrate to newer IDEs. But if I build this application in Visual Studio 2017 I'll get this error.
Error BC40004 sub 'PreInit' conflicts with event 'PreInit' in the base class 'Page' and should be declared 'Shadows'.
I think it's a problem with VB compiler version (again vs2013 builds project). Do you have any idea how to fix this?
My solution contains 40+ projects. The main project is asp.net webforms app written in VB.net. Other projects are services and code libraries written in C#.
I tried to specify VB.net version in .vdproj manually. But it didn't solve my problem.
edit: Fine. Thank you all for your responses. I got that problem is about code and that visual studio analyzer has changed a lot in the last few years. I'll try to find out the reasons why this code have been working without exceptions.
BC40004 is a warning, this shouldn't prevent you to compile the solutions unless you set the Treat warnings as errors on the project's property under the tab compilation.

BrowserLink MVC 6 - Not Working - No Extra Code Injected

How do I get BrowserLink to work in MVC6 - using RC1 Release 1. Using Visual Studio 2015 Update 1.
Browsers never appear in Browser Link dashboard. No extra js is injected or extra web calls made by site so it just seems to not be adding browser link code.
I have app.UseBrowserLink(). I am running in Development mode, debug. I have tried CoreClr and Full Framework. This happens even with a brand new Asp.net 5 web template with no changes made to it.
What else do I need to do? Does Browserlink actually work for anyone with ASP.NET 5 RC1?
I would also add I ran older projects based on MVC5 and Browserlink works on them without issue.
Seems to be an issue with the installation of "Microsoft ASP.NET 5 RC1 Update 1". Go into Control Panel > Programs and Features > Click "Microsoft ASP.NET 5 RC1 Update 1" and press Change > Repair.
Fixed it for me on three of my development machines.

AjaxControlToolkit 4.5 - Getting the Requires 4.0 Error Message Again

Here we go again. Using the latest April 2013 edition of AjaxControlToolkit 4.5 and I've done all the typical things we've seen over the past 6 months of getting it to work in our 4.5 projects. (changing the script manager, adding ajaxtoolkit to web.config, etc.)
Good news is, everything works wonderful locally. However, when deploying to IIS7 running 4.5 (well it's in there as 4.03 something) I'm getting that Tools Requires 4.0 error that we all love.
The issue is clearly at the server level since it works great in my environment locally. I'm using VS2012 and using a Web Application project. I'm using the publish mechanism to throw everything to the server, so maybe there's something it's not transferring there as well.
Been working on this for 4 hours last night and 4 hours so far today. Driving me crazy, so I figured I'd post this out there.
Ok got it. During a publish I checked the "Delete All Files" first and then did the publish. This must have finally wiped out the Ajax 4.0 things somewhere and then the app ran just fine.

Upgrade ASP MVC project from VS2008 to 2010 - is it possible not to upgrade to .net4 at the same time

I have a Vs2008 project using version2 of the ASP MVC framework. I tried to upgrade to VS2010. I fetched a new copy from svn and opened it. I got the expected conversion dialog, clicked next and then finish. A while later comes up a question do I want to also upgrade to the version 4 of .net framework.
I've done this same process twice wioth the same project. THe first time I clicked no and the second time I clicked yes. But, if i run a diff across the directories created, there's essentially no difference (some generated dlls differ and there's a path difference in the vbproj file but that's it). If, however, i diff the new and old project I get a whole load of differences. That's of course expected, but some of them seem to indicate that it's done the upgrade to .net4 anyway! For example, the vbproj file now referneces 4 instead of 3.5 as it's tools version and all the reference.vb files generated from the .wsdl files for my web references now have "Runtime Version:4.0.30319.1" instead of "Version:2.0.50727.4927" and Resources.Designer has a similar.
So, my question, should there be a difference between the version where I said "yes, upgrade the -net framework to version 4 for this project" and the version where I said no or does ASP run with the old version anyway? I really don't want to find that my new version doesn't work when deployed to production servers which may not have .net 4 installed!
You can always change it back to 3.5 in the project settings, so long as you don't upgrade the MVC version to MVC3. Some of those settings may say 4.0 because they depend on the VS2010 designer, which is based on 4.0, and thus needs to reference 4.0 versions at design-time.

VS2010 converted project invalid reference

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

Resources