Aspcompat performance issue

I am using the aspcompat page attribute in ASP.NET, so the com-com components I call can end up in ASP internal objects (Request, Response, Application, etc.)

I quickly created a new test project, one asp.net page and a vb6 com component.

The page does this:

for (int i = 0; i < 1000; i++)
            Application["string" + i] = i.ToString();
        Debug.WriteLine(string.Format("{0} done adding strings to app",Environment.TickCount));
        var asp = new ASPTest.CompClass();
        asp.SetProcessId();   

      

Basically I add stuff to the application object and then call it in a lump.

Set context = GetObjectContext
If Not context Is Nothing Then
    Set app = context("Application")
    Set ses = context("Session")
    Set resp = context("Response")
    If Not app Is Nothing Then
        OutputDebugString "" & GetTickCount & " writing response"
        resp.Write "I see application from vb <br/>"
        OutputDebugString "" & GetTickCount & " before "
        For i = 100 To 200
            resp.Write GetTickCount & " i = " & app("string" & i) & "<br/>"
        Next
        OutputDebugString "" & GetTickCount & " after "
    End If
Else
    OutputDebugString "No context"
End If

      

The problem is that the more things I put into the application, the slower the vb code gets. Not all code though, when I first try to call any method on internal objects, in my example my first call to resp.Write. If I add 10000 items to resp.Write app it takes ten seconds, 60000 => timeout.

It seems like when I touch any internal object, the first time the runtime does something nasty to make the objects COM available.

Have you ever seen this? Any suggestion is greatly appreciated.

0


a source to share


1 answer


This is almost certainly a threading issue, perhaps with the use of Interop performing thread context switches with every call from a VB component to classes in context.



I'm not an expert here, so I can (wil probably) get a fix, but I believe you need to make sure your VB component is also STA, just like the ASP.NET page tagged with aspcompat = true sets This. If you keep all the components in the same thread, there won't be any context switches (which require very expensive sorting).

0


a source







All Articles