locked
Unclear behaviour of same code RRS feed

  • Question

  • User1829281058 posted

    First let me tell about my setups :

    I am running Windows 7 Ultimate Service Pack 1 64 bit machine in Oracle Virtal Box. 10 GB RAM to this Virtual machine.
    Visual Studio Enterprise 2019 64 bit
    IIS 7.5

    I have two asp.net applications. Both have 3 textboxes and 1 command button. Below command button's code is same in both the applications.

    In Visual Studio IDE : Webapplications1--Right Click Properties--Web Option
    Server IIS Express
    Bitness : Default (Here if I choose either x86 or x64, I am getting below error, no effect!)
    Project URL : http://localhost:49162/
    Back to Webform1.aspx
    Runs the application by Clicking on IIS Express (Google Chrome)
    Browser opens : http://localhost:49162/WebForm1.aspx (It do not opens the page in chrome if I open a new tab seperately, says This site can't be reached)
    and says : Server Error in '/WebForm1.aspx' Application.

    The resource cannot be found.
    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /WebForm1.aspx

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3062.0

    While in the IIS (inetmgr.exe) under Default Web Site I have Webapplication1 and it is opening the C:\Users\gk\source\repos\WebApplication1\WebApplication1 when I right clicks and Explore it.
    Ok. Now I changes
    Server : Local IIS
    Project URL : http://localhost/WebApplication1
    Back to Webform1.aspx
    Control+S to save all the changes in project
    Runs the application by Clicking on IIS Express (Google Chrome)
    Browser opens : http://localhost/WebApplication1/WebForm1.aspx (It opens the page in chrome if I open a new tab seperately)
    and application runs. There are 3 textboxes in the application and one button. I puts some values in the textboxes and clicks on button I get :

    System.InvalidOperationException: 'The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.' at Con.open() line.

    This is all about Webapplication1.

    Ok. Now second application, same 3 textboxes, 1 button and same code of first apps:
    In Visual Studio IDE : Webapplications2--Right Click Properties--Web Option
    Server : Local IIS
    Project URL : http://localhost/WebApplication2
    Back to webform1.aspx
    Runs the application by Clicking on IIS Express (Google Chrome)
    Broswer open link : http://localhost:49269/WebForm1.aspx
    Run complete fine, no error at all.

    Ok, Now I changes :
    Server : IIS Express
    Project URL : http://localhost:49269/
    Control+s to save the changes
    Opens webform1.aspx
    Runs the application by Clicking on IIS Express (Google Chrome)
    Browser opens : http://localhost:49269/WebForm1.aspx
    Run complete fine, no error at all.

    Now, if I opens the link http://localhost:49269/WebForm1.aspx in chrome seperately it says :
    This site can’t be reached localhost refused to connect.
    Try:

    Checking the connection
    Checking the proxy and the firewall
    ERR_CONNECTION_REFUSED

    So, what is all these mystries. I have Enable 32-bit Application True in DefaultAppPool in IIS.
    For your info: here is my code : WebForm1.aspx.vb in both the applications.

    Imports System.Data.OleDb
    Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    InsertRow(Field1:=TextBox1.Text, Field2:=TextBox2.Text, Field3:=TextBox3.Text)
    End Sub

    Private Sub InsertRow(ByVal Field1 As String, ByVal Field2 As String, ByVal Field3 As String)

    Dim con As OleDbConnection
    Dim dBaseFile As String

    dBaseFile = "TestData.dbf"
    'Try
    '.NET Framework Data Provider for SQL Server
    'Data Source=gk-pc;Initial Catalog=msdb;Persist Security Info=True;User ID=sa;Password=***********
    con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=dBASE IV;")
    'con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\;Extended Properties=dBASE IV;")
    'Create a new instance of the command object
    Using cmd As OleDbCommand = New OleDbCommand("INSERT INTO " & dBaseFile & " ([Field1], [Field2], [Field3]) VALUES (@f1, @f2, @f3)", con)
    'Parameterize the query
    With cmd.Parameters
    .AddWithValue("@f1", Field1)
    .AddWithValue("@f2", Field2)
    .AddWithValue("@f3", Field3)
    End With
    con.Open()
    cmd.ExecuteNonQuery()
    con.Close()
    End Using
    'Catch ex As Exception
    'Console.WriteLine(ex.Message)
    'Finally
    If con IsNot Nothing Then
    If con.State = ConnectionState.Open Then
    con.Close()
    End If
    con.Dispose()
    End If
    'End Try
    End Sub
    End Class

    This is my first post, so please bear with me for bad english and/or forum rules, if I am not following them properly.

    Saturday, May 11, 2019 5:14 PM

All replies

  • User-1174608757 posted

    Hi,GirishSharm

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

    404 error means it couldn't find the resource,so I suggest that you could check that you have started local iis express for your application site.Here is the link for check iis express:
    https://stackoverflow.com/questions/9955696/how-do-i-start-stop-iisexpress-server

    The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.' at Con.open() line.

    The issue I described in my question occured basically due to the incompatibility of the Microsoft.Jet.OLEDB.4.0 driver in 64 bit OS.

    So if we are using Microsoft.Jet.OLEDB.4.0 driver in a 64 bit server, we have to force our application to build in in 32 bit mode (This is the answer I found when I did an extensive search for this known issue) and that causes other part of my code to break.

    Fortunately, now Microsoft has released a 64 bit compatible 2010 Office System Driver which can be used as replacement for the traditional Microsoft.Jet.OLEDB.4.0 driver. It works both in 32 bit as well as 64 bit servers. I have used it for Excel file manipulation and it worked fine for me in both the environments. But this driver is in BETA.

    You can download this driver from link 

    https://www.microsoft.com/en-us/download/details.aspx?id=13255

    Best Regards

    Wei 

    Monday, May 13, 2019 8:25 AM