1

In my solution, there are several projects. One project was upgraded to .NET Framework 4.5.2. All other projects are using the version .NET Framework 4.5.1. The project upgraded is the main site (root), other projects are sub sites. The sites are hosted to the server. The sub sites are working and the main site not working. The server having the version .NET Framework 4.6.

When I run the main site, the site shows Object reference error.

Source code changes in project file Changes in <code>.csproj</code> file

Error Site showing error

EDIT: The site is working fine when I run the application from Visual Studio 2013. I did not get any Object reference error. When I published and deployed the site in the server, it is not working, showing the Object reference error.

NOT AN ISSUE: I found the issue, somebody in the team changed the appSettings value in web.config changed in server, that cause the issue. I thought it was because of .NET Framework upgrade issue, because no other code changes done in the application. I appreciate all for your valuable comments.

Jesuraja
  • 3,774
  • 4
  • 24
  • 48
  • 4
    What is ".NET Framework 6.0"? AFAIK the latest version is 4.7. – phuzi Jun 20 '17 at 08:18
  • Just out of curiosity, try `True` instead of `` – Keyur PATEL Jun 20 '17 at 08:20
  • 3
    The exception occurs in your code, so where's your code? – CodeCaster Jun 20 '17 at 08:21
  • .Net Framework 4.6. Typo error – Jesuraja Jun 20 '17 at 08:47
  • I checked my source code with previous version (before upgrade). No changes found other than .csproj file change and web.config changes. In web.config, the targetFramework attribute value changed from **4.5.1** to **4.5.2** – Jesuraja Jun 20 '17 at 08:50
  • 2
    Read [ask], create a [mcve] that shows the relevant code. Changing the target framework from 4.5.1 to 4.5.2 is not going to throw random NullReferenceExceptions, otherwise many people would've had the same issue before you. Without any code, this can't be answered. See duplicate for how to debug it yourself if you don't want to show the code. – CodeCaster Jun 20 '17 at 09:10
  • @CodeCaster See my edit, No other changes done in files. Any other issues? Do I need to upgrade all the project to upgraded version? If the error in code, why it is working when I run the application from Visual Studio? I can debug and fix the Null Reference error, if it is identified. So I am suspecting the Upgradation of Framework. – Jesuraja Jun 20 '17 at 09:16
  • 2
    upgrading one point-version will not cause breaking changes which would would make this happen. Something else has changed as well, you just need to find it. Could be the underlying data that's changed (trying to populate something from a NULL database object), or someone has changed some code without remembering. Without the relevant code that's causing the error, we can't say. But if it works on one environment and not another, I would suspect the data or (the absence of?) another deployed artefact in the non-functioning environment. – ADyson Jun 20 '17 at 09:20
  • 2
    Yeah for all we know that code is trying to load a resource, plugin, XML file or whatever artifact @ADyson mentions which isn't deployed with this new deployment. You can be 99% certain the framework upgrade didn't cause this error. You can keep guessing, or take a good hard look at your code again, perhaps add some logging if it only occurs on the server. – CodeCaster Jun 20 '17 at 09:36
  • I found the issue, somebody changed the appSettings value in web.config changed in server, that cause the issue. I thought it was because of .NET Framework upgrade issue, because no other code changes done in the application. Thanks for all for your valuable help. – Jesuraja Jun 21 '17 at 09:19
  • @Jesuraja *all* your projects use 4.5.2, or whatever the installed runtime is. That's because versions after 4.0 are binary replacements. If someone installs 4.7, all projects run on that single 4.7 runtime. The version number in the config file affects the behaviour of *some* functions – Panagiotis Kanavos Jun 21 '17 at 09:28

0 Answers0