0

I recently upgraded an application that was .NET 3 to .NET 4. I did this automatically by loading it into Visual Studio 2012 which did the upgrade. This application communicates with another server via remoting. The application works perfectly fine on the old version, but after upgrading it I get the following error:

[NullReferenceException: Object reference not set to an instance of an object.]

I believe this is happening because of the following :

tempObj = Activator.GetObject(GetType(Tech.Service.Interfaces.IGetTechRates), ConfigurationManager.AppSettings("TECHser"))

The null reference is happening at the following line:

Dim TechDV As DataView = New DataView(ods.Tables(0), _
                                  sRowFilter, _
                                  sSortExpression, _
                                  DataViewRowState.CurrentRows)

Where ods is:

ods = tempObj.GetTechList

I have both versions of the application, and I have been switching between the two of them. The .NET 3 version works fine but the .NET 4 version is giving problems.

This is not a question about what NullReferenceException is. I am asking what happened during the upgrade that could have caused this, since Visual Studio said that everything should work as before.

abden003
  • 1,177
  • 5
  • 23
  • 48
  • Almost all cases of `NullReferenceException` are the same. Please see "[What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net)" for some hints. – John Saunders Jun 16 '15 at 23:35
  • I don't really see why this is not a duplicate of the above-linked question. There's a value you expected would never be null. You were mistaken about that. As a result, you got a NullReferenceException. Am I wrong about that? – John Saunders Jun 16 '15 at 23:37
  • I was wondering how the upgrade could have caused it, since it works perfectly fine with the older version. The NullReference is a side effect that has happened because of the upgrade. – abden003 Jun 16 '15 at 23:39
  • I'd break that down a bit further if I were you. Something now returns null where it didn't before, and chances are this is related to the upgrade. Find out what is returning null, then find out _why_, and you may find which aspect of the upgrade is causing this. For instance, it might not be the .NET Framework version - it might be some other action you took during the upgrade process. – John Saunders Jun 16 '15 at 23:42
  • Is this deployed to the same server or a new server? Do you have to install some kind of third party library (IGetTechRates) on the server? On the line in question it looks like there are three objects that could possibly be NULL. Do you know which it is? (`DataViewRowState`, `ods` or `DataView`) – Nick.McDermaid Jun 17 '15 at 00:32
  • If this is happening directly in VS during debug mode (it helps to know these things), another reason could for example be that some kind of change to the way data is filtered (case sensitive for example) means that `DataView` no longer returns records. Another reason could be that your remote host is no longer accessible because you have a special firewall exception based on something the VS exe name. This is really only to illustrate that we are **guessing** unless you provide a bit more info. There are so many different things that could have gone wrong – Nick.McDermaid Jun 17 '15 at 00:39

0 Answers0