none
.NET 4.0 framework issue on Windows Server 2012 R2 but not on Windows Server 2008? RRS feed

  • Question

  • I have a Silverlight application that with WCF web services that use .NET framework 4.0 target.  Silverlight application and web services are on the same web server.

    I deploy the application to two different web servers:

    Server 1 - Windows Server 2008 Standard SP2

    Server 2 - Windows Server 2012 R2 Datacenter

    On server 1 my application and web services run perfectly, no errors.  

    On Server 2 the web services code triggers an error  "Object reference not set to an instance of an object".  My first thought was difference in data being consumed, so I made sure the data used was identical to the data being used by Server 1, still same error.  Next step is to executed code from within my Visual Studio environment and see if the error triggers in my debug session pointing to the same data, but no errors.

    Next step was to add temporary "debug" code that would write to a log file so I could see exactly what is happening on Server 2.  After looking at the results of my logging from Server 2 the error just doesn't make ANY sense at all, there should NOT be an "Object reference not set to an instance of an object" error ... here is the code sample:

            Try
    
                Dim tProvider As New DC.Database.Tools
                Dim DBCommand As New SqlCommand
                Dim DBAdapter As New SqlDataAdapter
    
                ' TEMP CODE: remove when done
                Dim tmpLog As New Log
                If Me.DBConnection IsNot Nothing Then
                    tmpLog.WriteErrorEventToFile(Me.DBConnection.ConnectionString, 666, "TransactionBalances.Update", "857", "", "")
                End If
    
                tmpLog.WriteErrorEventToFile(Me.SiteID, 666, "TransactionBalances.Update", "860", "", "")
    
                If QueryBy_TransactionBalancesID_SiteID(DBCommand, Me.TransactionBalancesID, Me.SiteID) Then
    
                    Dim dtTransactionBalances As New DataTable
    
                    If tProvider.Query(dtTransactionBalances, SQLFormatting.ResultType.Data_Add_Update, Me.DBConnection, DBCommand, DBAdapter) Then
    
                        If dtTransactionBalances IsNot Nothing Then
                            tmpLog.WriteErrorEventToFile(dtTransactionBalances.Rows.Count.ToString, 666, "TransactionBalances.Update", "869", "", "")
                        End If
    
                        Select Case dtTransactionBalances.Rows.Count
    
                            Case 0 ' Add 
    
                                If Me IsNot Nothing Then
                                    tmpLog.WriteErrorEventToFile(Me.TransactionBalancesMAPID.ToString, 666, "TransactionBalances.Update", "877", "", "")
                                End If
    
                                If DBAdapter IsNot Nothing Then
                                    tmpLog.WriteErrorEventToFile(DBAdapter.InsertCommand.ToString, 666, "TransactionBalances.Update", "881", "", "")
                                End If
    
                                tmpLog.WriteErrorEventToFile(vState.ToString, 666, "TransactionBalances.Update", "884", "", "")
    
                                Select Case vState
                                    Case Info.UpdateState.Normal
    
                                        If tProvider IsNot Nothing Then
                                            tmpLog.WriteErrorEventToFile(tProvider.DatabaseCommand.ToString, 666, "TransactionBalances.Update", "890", "", "")
                                        Else
                                            tProvider = New DC.Database.Tools
                                        End If
    
                                        Update = tProvider.Add(dtTransactionBalances, Me, Me.DBConnection, DBAdapter, Me.TransactionBalancesMAPID, , TABLE_NAME, "TransactionBalancesID", Me.TransactionBalancesID)

    The tmpLog is my debug code that does the logging to text file.  The error is triggered by the the last line of code in the above code segment.  

    "Update = tProvider.Add(..."  Note: "Update" is the method name and is a boolean value, initiated to False prior to reference.

    As you can see form my code I've verified every other object has been instantiated.  But for some reason tProvider will just NOT be substantiated??  But again this ONLY happens on Server 2, the exact same code works fine on Server 1.

    I've never ever seen anything like this before.  Is this a Windows Server 2012 R2 problem, or some .NET 4.0 framework incompatibility with Windows Server 2012 R2?  As I understand it Windows Server 2012 R2 comes with .NET 4.5 framework as part of the OS installation ... I did verify it was installed.  I'm assuming that includes .NET 4.0.

    As this point, I'm lost as to how to resolve this?  Anyone else come across this problem?

    Cheers, Rob.





    Sunday, September 25, 2016 6:28 PM

All replies

  • Hi Robin Ainscough,

    Thank you for posting here.

    For your question, .NET 4.0 framework incompatibility with Windows Server 2012 R2.

    .NET 4.0 framework support:

    • Windows XP SP3
    • Windows Server 2003 SP2
    • Windows Vista SP1 or later
    • Windows Server 2008 (not supported on Server Core Role)
    • Windows 7
    • Windows Server 2008 R2 (not supported on Server Core Role)

    .NET Framework 4.6.1 support:

    • Windows 7 SP1 (x86 and x64)
    • Windows 8 (x86 and x64)
    • Windows 8.1 (x86 and x64)
    • Windows 10
    • Windows Server 2008 R2 SP1 (x64)
    • Windows Server 2012 (x64)
    • Windows Server 2012 R2 (x64)

    If you want it work on Windows server 2012 R2, you could install .NET Framework 4.6.1.

    I hope this would be helpful to you.

    If you have something else, please feel free to contact us.

    Best Regards,

    Wendy


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, September 26, 2016 7:22 AM
    Moderator
  • Thanks for the response Wendy.

    Along similar lines I converted the Target of my project to .NET Framework v4.5.2 since both Windows Server 2008 SP2 and Windows Server 2012 R2 list as supported.

    Unfortunately that did NOT make a difference, the exact same error in the same location on Server 2 but again no error on Server 1.

    What has me so puzzled is that 99% the other aspects of my code work (even the same references to tProvider) in the very same DLL (project) on Windows Server 2012 R2 all work as expected, just that one method triggers an error on Windows Server 2012 R2, but NOT on Windows Server 2008 SP2.

    I'm just completely baffled?  

    FYI, .NET Framework 4.6.1 (or 4.6.2) is not supported on Windows Server 2008 SP2 so that's currently not an option until that server is upgraded.  

    Cheers, Rob.


    Monday, September 26, 2016 3:11 PM
  • Hi Robin Ainscough,

    Thank you for feedback.

    For your question, in the last line of your code, what does the " ,   ," mean in your code?

    Update = tProvider.Add(dtTransactionBalances, Me, Me.DBConnection, DBAdapter, Me.TransactionBalancesMAPID, , TABLE_NAME, "TransactionBalancesID", Me.TransactionBalancesID)

    And what is the add method?

    More details would be helpful for us to give you a solution.

    Best Regards,

    Wendy


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, September 27, 2016 8:39 AM
    Moderator
  • Hi Wendy,

    I believe you are missing a key point, the exact same code going to the exact same data source works on Windows Server 2008 SP2 under IIS7, but does NOT work under Windows Server 2012 R2 with IIS 8.5.

    The log file (tmp

    If tProvider IsNot Nothing Then
                                            tmpLog.WriteErrorEventToFile(tProvider.DatabaseCommand.ToString, 666, "TransactionBalances.Update", "890", "", "")
                                        Else
                                            tProvider = New DC.Database.Tools
                                        End If
    
                                        Update = tProvider.Add(dtTransactionBalances, Me, Me.DBConnection, DBAdapter, Me.TransactionBalancesMAPID, , TABLE_NAME, "TransactionBalancesID", Me.TransactionBalancesID)

    The line of code below "tmpLog.WriteErrorEventToFile(tProvider.DatabaseCommand.ToString, 666, "TransactionBalances.Update", "890", "", "")" never gets executed ... it's NOT in my logging/trace file.  This means that tProvider is "nothing", yet as you can clearly see from the code "tProvider" is instantiated early in the code.  And to ensure tProvider is instantiated I AGAIN execute "tProvider = New ..." ... but when I get to the "Update = tProvider..." line the "Object Reference not set to an instance of any object" error is triggered.  If you look at all the code leading up to this error you can see I verify all the values being passed as parameters in the tProvider.Add method.

    I feel you are looking at this problem from the wrong angle, you can't ignore that this exact same code work both from Windows Server 2008 SP2 and from my on debug session from within VS 2015 on my development computers, ONLY under Windows Server 2012 R2 do I get this bizarre problem.

    Cheers, Rob.


    Tuesday, September 27, 2016 4:21 PM
  • Wendy is suggesting your code is not complete on that line and therefore will not compile, and is requesting confirmation from you whether it's because you manually reducted sensitive information without putting placeholder there, or it's typo that you typed duplicate commas on that line, or else.

    Code that cannot be compiled cannot be tested. Please try to provide something compilable when you seek help from others.

    Wednesday, September 28, 2016 1:42 AM
    Answerer
  • I don't understand your statement?  Please re-read my original post in this thread.  The code is deployed to my web servers (Windows Server 2008 and Windows Server 2012 R2) ... one can't deploy code that doesn't compile, that's impossible.  

    My code sample, the last line triggers the error but it is NOT the complete block of code as I was just showing the relevant sample ... I'm not going to provide my entire applications as it is confidential.  But again, this issue IS NOT the code (it compiles, deploys, and runs fine on 3 computers under IIS).  The issue is that the EXACT same complied and deployed code works (as in no errors) on Server 1 (Windows 2008 Server SP2) but not on Server 2 (Windows 2012 Server R2) where the only difference is that Server 1 is Windows Server 2008 IIS7 and Server 2 is Windows Server 2012 R2 - IIS8.5.

    Again, please re-read my original post as it defines the problem which is NOT a coding problem which is what you and Wendy seem to want to focus on and I'm not sure why?

    The direction I would expect this thread to go would be related to IIS7 and IIS8.5 and .NET version support and possibly some incompatibility and/or settings for IIS8.5 under Windows Server 2012 R2 that might cause strange errors in .NET compiled and deployed .NET code. 

    Cheers, Rob.


    Wednesday, September 28, 2016 4:35 AM
  • Try copy and paste the following line to Visual Studio:

                                        Update = tProvider.Add(dtTransactionBalances, Me, Me.DBConnection, DBAdapter, Me.TransactionBalancesMAPID, , TABLE_NAME, "TransactionBalancesID", Me.TransactionBalancesID)


    Before it complains "The name <something> is missing in the current context.", it will tell you "Argument is missing" between the two commas because that is invalid syntax.

    This obviously couldn't be the exact code you've deployed because it won't compile. Usually it is caused by reducted code or, God forbids, manually typed code based on your production code so it can have typing mistakes.

    If it can have typing mistakes, we can't be confident that we've found your problem even if we somehow managed to reproduce the behaviour you described. And that is the problem.



    Wednesday, September 28, 2016 4:50 AM
    Answerer
  • tProvider is instantiated from my own class DC.Database.Tools

    the "Add" method of the DC.Database.Tools class (tProvider is the instance) is overloaded and has 5 optional parameters ... so these "Me.TransactionBalancesMAPID, , TABLE_NAME, "TransactionBalancesID", Me.TransactionBalancesID" are all optional and hence the ", ," is valid.

    It is the exact code that compiled and deployed, no syntax mistakes and all valid to VB.NET constructs.

    Cheers, Rob.


    Wednesday, September 28, 2016 5:10 AM
  • That answers Wendy's question - it's because the .Add() method has optional parameters.

    Back to the topic, I see that you've added check to DBAdapter.InsertCommand but not DBAdapter.UpdateCommand. I suggest you to try add that checking to see if it's related.

    Btw, without knowing what is done in tProvider.Query() we cannot suggest what can be the difference.

    Wednesday, September 28, 2016 6:57 AM
    Answerer
  • I'm sorry, but you seem to be not understanding the issue or looking for a cause in the wrong place (i.e. code).  I don't know how to keep stressing this any more than I have ... the exact same compiled code works flawlessly on 3 computers (2 development PC's running VS 2015) and a "deployed" Windows Server 2008 SP2 IIS7 machine.  The ONLY machine the EXACT same code is NOT working on (generating errors that make no logical sense) is a Windows Server 2012 R2 IIS8.5 machine.  This IS the issue, NOT THE CODE ... the server IS the only difference in this equation, all point to the same SQL data source.

    Your responses are excluding the possibility that their could be a Windows Server 2012 R2 II8.5 issue with .NET framework ... or maybe their is some other option under IIS8.5 that could trigger .NET web applications to have erratic behavior that makes no logical sense.

    I presented to code to show you that the error being generated does NOT make logical sense and shouldn't exist ... my code verifies values all leading upto the "Object Reference not..." error.  Please please please read my responses carefully, it will help you understand why it would be IMPOSSIBLE to get an "Object Reference..." error.  The focus should not be the code, the focus should be a problem with IIS8.5 and/or Windows Server 2012 R2 and/or VM.

    I will add that both Server 1 (Windows 2008 Server SP2) and Server 2 (Windows Server 2012 R2) do operated under VM.  A quick Google search and I see many many many threads about Windows Server 2012 R2 performance problems and .NET problems under VM.  A clue perhaps?

    Cheers, Rob.


    Wednesday, September 28, 2016 4:00 PM
  • FYI, most of the .NET framework BCL source code can be found on http://referencesource.microsoft.com/ If we can know what exact classes and methods they're using in the code, we may be able to tell you want could possibly be the problem in the .NET framework runtime.

    For example, we did find an ArgumentOutOfRange bug on .NET runtime DateTime.Now that only exist on certain timezone on specific daylight saving time difference. And the bug was originally thrown by a ComponentOne component. Had he did not provide full stack trace to the origin of exception, we will not be able to tell him about it.



    Wednesday, September 28, 2016 4:09 PM
    Answerer
  • I'm using the latest versions:

    Microsoft.Bcl v1.1.10

    Microsoft.Bcl.Async v1.0.168

    Microsoft.Bcl.Build v1.0.21

    At least NuGet package manager reports them as the most recent.

    Cheers, Rob.

    Wednesday, September 28, 2016 5:17 PM
  • Hi Robin Ainscough,

    Thank you for feedback.

    >>The issue is that the EXACT same complied and deployed code works (as in no errors) on Server 1 (Windows 2008 Server SP2) but not on Server 2 (Windows 2012 Server R2) where the only difference is that Server 1 is Windows Server 2008 IIS7 and Server 2 is Windows Server 2012 R2 - IIS8.5.

    According to your description, it works well in Windows Server 2008 with IIS7 but failed in Windows Server 2012 R2 with IIS8.5.

    Could you provide more details about your logs of IIS8.5?

    And you could use try catch to catch exception by using Log4Net.

    More details would be helpful.

    If it is more related to IIS, you could post in IIS Forum for support.

    Thanks for your understanding and cooperation.

    Best Regards,

    Wendy


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 29, 2016 10:38 AM
    Moderator
  • Hi Wendy,

    We're going to wipe the Windows Server 2012 R2 under VM and install Windows Server 2008 R2 under VM and see if that resolves the issue.  I'll report back if that solves the problem.

    I can't present the logs as they contain sensitive and confidential information, but I can tell you that the logs indicate that "tProvider" will NOT get Instantiated (everything else in that method does get Instantiated with correct/expected values) ... as per my response (item #5 in this thread).

    Cheers, Rob.

    Friday, September 30, 2016 3:07 PM
  • Hi Rob,

    >>We're going to wipe the Windows Server 2012 R2 under VM and install Windows Server 2008 R2 under VM and see if that resolves the issue.  I'll report back if that solves the problem.

    What's the problem now? Do you have any updates? it could be also for someone who has the same issue.

    Comparing with these two test environment, it should be Ok. From our side, it is hard for me to locate where the issue is. I also suggest you make two clean machines to confirm whether there are other factors. For example, registry or third-party software or others. Anyway, test will be first.

    Hope you bring good news!

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 18, 2016 5:55 AM
  • Hi Kristin,

    We have NOT been able to resolve the issue after doing the following:

    1.  Spin up a new VM and installed Windows Server 2008 R2 Standard (IIS 7)

    2.  Installed .NET framework 4.5.2 (nothing else)

    3.  Did NOT setup SSL (remove any possible variables) so standard HTTP

    4.  I added debug code to write out all values to file EVERY step of the execution path and NONE of the variables are Nothing/Null.  Every single variable/object instances is being instantiated. Yet we get the same error "Object Reference not set to an instance of an object".

    5.  Verified the ApplicationPool is set to .NET framework v4.0.  Identity is set to NetworkService (but we tried ApplicationPoolIdentity also and no difference).  NOTE: under IIS7 there is no option to set it to .NET framework v4.5, v4.0 is the only choice.

    I can execute the EXACT same code from my Test Server pointing the exact same data and there are NO errors.  I can execute the EXACT same code from within VS 2015 pointing to the exact same data and there are NO errors.

    We're really out of options, I have NO idea why we're having this problem.  The ONLY variable that hasn't been removed from the equation is VM ... but our other test server runs under VM also, only difference is that it's Windows Server 2008 SP2 (not R2) but still running IIS7.

    So NO RESOLUTION and I currently have exhausted all my options.

    Rob.


    Tuesday, October 18, 2016 4:48 PM