ASP.NET wont load a worker process for an odbc connection RRS feed

  • Question

  • Hi everyone.

    I am facing a strange problem which started to happen a couple of days ago but didn't happend before.

    I have developed a .NET assembly to be used from a classic ASP web site through interop. In this assembly I perfom read/write operations against a SQL Server database and an ODBC-enabled database (MYOB). The assmebly does all the work and it is working fine. I've tested it from a windows application without any problem. Then, last week, I called the assembly from the ASP page using the COM wrapper and it worked too.

    I added more reagind operations to the assembly but it stopped working in the ASP web site. If tested using the windows application ervrything works fine though. So I created a ASP.NET web site to test the assembly using a web site rather than a windows application so I could debug the assembly. I got the same errors in the ASP.NET Web site but this time I was able to debug and compare with the windows application (I though it could be a permission issue)

    The difference is this: when the Open() method of the ODBCConnection object is called in the windows application the worker process of the MYOB database is risen (myobp.exe) and when the Close() methdod is called, that process is ended, which is what one should expect. However, using the ASP.NET web site the myobp.exe process is started but inmeadiately finished, without reason or error (I checked this looking at the task manager. It also shows that the user running myobp.exe is ASPNET, which is confusin becuase the virtual directory has impersonation enabled).  The code continues to run, it creates transactions and executes queries (ExecuteNonQuery method) but when it reaches the Commit method of the odbc transaction object I get the error "No valid MYOB application is running". I am using the same assembly in both projects, windows and web.

    Either with impersonation in the virtual directory set to use an Local Administrator or impersonation disabled result was the same. I also used programmatic impersonation in the assembly, again using an administrator account, but I got the same result. I also granted permissions in the virtual directory to allow Scripts and Executables file to run, but nothing!

    I am new in ASP.NET so I was wondering if the logon user and the Current principal have something to do with this, which would be very strange since I've already used impersonation with the same results.

    With impersonation enalbed I got this:

    Response.Write(HttpContext.Current.User.Identity.Name);  //Blank

    Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name);  //Aministrator account used for impersionation

    Response.Write(System.Threading.Thread.CurrentPrincipal.Identity.Name); //Blank

    I even set

    System.Threading.Thread.CurrentPrincipal = new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent());


    But nothing changes. The debuggin shows that the current execution user is set to the administrator account, not ASPNET, but the database worker process and the database locking files are all risen/locked by ASPNET.

    The web site works only when I run it directly from Visual Studio using the VS virtual services. However, in this case, the current WindowsPrincipal, current thread identity and the user who raises the myobp.exe process are all the same, I mean, the local user (administrator in this case), so everything works fine!

    Any help would be very much appreciated!!!




    Tuesday, January 27, 2009 4:14 AM

All replies

  •  I've tried the web site in a Win Server 2003 with IIS 6

    I had some problems at the beginning with the security policy. I was getting Request for the permission of type 'System.Data.SqlClient.SqlClientPermission [.....]' failed exception and then with the odbc connection. After adding the permission sets the problem was solved. However, I couldn't solved the SecurityException I was getting due to the programmatic impersonation so I removed the impersonation from code and enabled the impersonation in the virtual directory (just for testing) using a local administrator account.

    It worked! No problem at all. I guess I just need to fix the policy settings for the application in the server. However, I don't understantd why it does not work in my pc. Wha't's the difference? And again, why the seb site loades a process on behalf of the ASPNET account if impersonation is being used?

    I need to do more development on my machine, how can I fix this?

    Thursday, January 29, 2009 12:09 AM