com surrogate error

Topics: Developer Forum
Coordinator
Mar 30, 2010 at 5:17 PM

What does a com surrogate error means on a workstation (webserver) that has activevfp.dll on it?  Basically when you click the details, it's somehow point to the VFP9T.DLL under the error signature:

The current setup is as follows:

program (prgs/html), activevfp are local to this webserver.  Data is coming from a different machine which is mapped on the webserver as X:\Data.  I can access the data fine, save a couple of changes in the database but there will be intermittent display of this error appearing on the webserver I and can't seem to connect/figure out this error on the actual website being accessed.  Any ideas?

Thank you,

Aldrin

Coordinator
Mar 30, 2010 at 5:26 PM

Here's the actuall error I'm getting in the browser side..

Caught .NET exception, source: activevfp_dotnetproxy message: The remote procedure call failed. (Exception from HRESULT: 0x800706BE)

Coordinator
Mar 30, 2010 at 8:03 PM

Are you using COM+ to impersonate a user that has rights to that drive?

Coordinator
Mar 30, 2010 at 8:52 PM
Edited Mar 30, 2010 at 8:54 PM

Yes, as instructed on the documentation.

COM + Setup Instructions for a VFP mtdll (on Windows2000):

1.) go into Control Panel, Component Services
2.) right click COM+ applications and select New.
3.) going through the wizard, create an Empty Application, giving it a name, check server application, and select the appropriate   account to run under.
4.) After the Empty Application is created, right click on 'Components' under the newly created application.
5.) select New/Component.
6.) The wizard starts - select 'Import components that are already registered.'
7.) select your Visual FoxPro mtdll from the list and it is added to this COM+ app.
8.) right click on your COM+ application name and select 'Start'. The COM+ icon is now revolving in the Components pane.

I can see that the com actually works since i can access my data fine when testing from the interface (browser).  It's just intermittently that I get that error (caught .NET exception, source: activevfp_dotnetproxy message: The remote procedure call failed. (Exception from HRESULT: 0x800706BE)) in the browser side and if I go to the webserver hosting the website I got the window prompt that has the COM Surrogate error.

Coordinator
Mar 30, 2010 at 9:19 PM

Does the data update actually happen and you still get the message or no update at all when you get the message?  Can you test that? 

I remember seeing this someplace but I don't remember what was done.  COMReturnError should help with any COM error and I assume that's still in your error handler.

Coordinator
Mar 31, 2010 at 1:40 AM

When I actually got the error in the browser, I was just merely retrieving data, I was not even committing on a table.  After getting that error and closed the browser and sign on again, it works again normally (can retrieve data no problem).  Where could I see the COMReturnError?  Is it in the main.prg?

Coordinator
Mar 31, 2010 at 2:24 AM
Edited Mar 31, 2010 at 2:25 AM

It's actually in the Error method in activevfp.prg.  If you want to try some things specifically with the error you're getting either subclass the Error method (if possible) and modify or modify directly.

 

Coordinator
Mar 31, 2010 at 2:35 PM

Thanks Claude for the response.  I'll take a look at the COMReturnError under the activevfp.prg and investigate further.

Coordinator
Apr 1, 2010 at 6:05 PM

Hello Claude, in the activevfp.prg ERROR function, there's a line here that is like so:

STRTOFILE(lcErrMsg,lcAppStartPath+'ErrorLog\'+;
lcAppName+'\error.txt')

I could not find this error.txt in the computer where the application is being hosted and I'm assuming if there will be an error that it will dump in the server with information about the error.  If I alter the activevfp.prg, do I need to recompilte the dll itself or just the PRG?

Here's an error event I found out in the Event viewer of the server.

Event Type:    Error
Event Source:    COM+
Event Category:    Unknown
Event ID:    4786
Date:        01/04/2010
Time:        12:25:27 PM
User:        N/A
Computer:    WEBSERVER
Description:
The system has called a custom component and that component has failed and generated an exception. This indicates a problem with the custom component. Notify the developer of this component that a failure has occurred and provide them with the information below.
Component Prog ID:
Server Application ID: {F561B2D9-AAAE-4495-9146-6D83C0862DCA}
Server Application Instance ID:
{766E3D20-4A28-4AFC-BB45-F88D7D97CBF8}
Server Application Name: maxonline
The serious nature of this error has caused the process to terminate.
Exception: C0000005
Address: 0x0C0E2C41
Call Stack:
VFP9t!DllOleInit + 0x3C2AA
VFP9t!DllWinMain + 0x6FF5C
VFP9t! + 0x2A76D
VFP9t! + 0x2B88E
VFP9t!DllWinMain + 0x661C4


For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

 

 

 

Coordinator
Apr 1, 2010 at 7:40 PM

Thanks for the detail.  You'll need to recompile the ActiveVFP project into the activevfp.dll since the change is to activevfp.prg.  Leave main.prg as marked external.

 

Is this application really busy or moderately busy? 

Coordinator
Apr 1, 2010 at 8:06 PM
Edited Apr 1, 2010 at 8:10 PM

I'll try to recompilte it then.

The application is moderately busy right now, that's why I'm confused why the com+ error.  Currently there's an average 200 users that can potentially connect to the website and it's growing,

though on a daily basis the website is being hit only by less than 20 users at the moment.

By the way, I got another error on the browser side today.

It says "There are too many people accessing the website at this time".  Doubt it's really a bandwith issue, since when I connected to the webserver to check,  a window with the Com Surrogate error is present.

Coordinator
Apr 1, 2010 at 8:44 PM

You may want to stress test with some automated tool. 

My preference is to figure out why this error occurs in COM+ but, if worse comes to worse,

your option might be to either move or make a copy/snapshot of the db and keep it on the web server so you don't have to use COM+.

 

Coordinator
Apr 1, 2010 at 9:03 PM

Any suggestion on these stress test tool automated tools?

The idea of having the data in the webserver is not an option at this time.  The actual webserver is just an XP box with 1Gb RAM, 500GB HD and a dual-core processor.  The data server is in an actual server machine. 

The database is also being accessed by the way by desktop application (written as well in foxpro).  Currently there can be 10 or more users/workstation being connected to the database.

If we go on a SQL database, will the activevfp be running in COM+ as well?

Coordinator
Apr 1, 2010 at 9:18 PM

Try the free WCat from Microsoft: http://www.iis.net/community/default.aspx?tabid=34&i=1466&g=6  for stress testing.

Yes, you'd have to use COM+ for SQL Server as well.  My preference is to find a solution to your COM+ problem so I'll do what I can to help. 

 

Coordinator
Apr 1, 2010 at 9:25 PM

Thanks for the link on the tool.  I'll try to use this during the weekend and see what results will it produce.  Thanks again for answering all my queries.

Coordinator
Apr 12, 2010 at 5:34 PM

We tested 2 simultaneous connection accessing the a test webserver and the com surrogate error still appears.  If I need to re-compile the mtdll, what do I need to change in the test webserver that has activevfp demo installed so that the

website that is using this project will instead point to the new dll.

Coordinator
Apr 12, 2010 at 6:29 PM
Edited Apr 12, 2010 at 6:30 PM

The default.aspx creates and calls the main method of activevfp.dll.  So you can either re-compile to activevfp.dll or change the name of the mtdll it calls in default.aspx.

Here are some more things to try that I found (I googled "com+ com surrogate"):

http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/51500109-a78b-4c16-8a84-7ab62c7c65d9

http://www.ureader.com/msg/1639109.aspx

 

Coordinator
Apr 12, 2010 at 6:40 PM

I don't think you told me what OS/IIS version you're using?  It appears there might be some magical combination of settings that may help:

"This problem has been isolated to the IIS Web Application that MailEnable creates when webmail is published to an IIS 6 web site. It appears that IIS 6 does not like running these web applications as isolated processes.
As such, these virtual directories need to be reconfigured. A revised version of the MEInstaller.exe file allows you to set these to change the process isolation level to low or shared (rather than high)."

from http://forum.mailenable.com/viewtopic.php?t=2302

 

Coordinator
Apr 12, 2010 at 7:04 PM

Does the COM Surrogate pop up an error box on the server and stops the application from working until you close it???

This one addresses that problem:  http://www.whoismadhur.com/2007/05/23/com-surrogate-error-fix/

 

Well there's a lot of stuff out there on the web for this.  Running a vfp mtdll in com+ is pretty much the same as running a vb6 dll the same way

so I'm confident others have fixed this somehow since there were/are so many VB6 users.  Please stay with us and let us know if you fix this - it'll help a lot of others...

 

Coordinator
Apr 12, 2010 at 7:23 PM

The OS is XP Professional with SP3.  Machine is currently running with Pentium D (Dual core) 2.8, 2Gb RAM and about 80GB of HD space.

I'm going to check out the last link that you posted.  This is basically what's happening on the webserver, an error box appear and stops the application until you close it.

 

Coordinator
Apr 12, 2010 at 7:28 PM

Here's the last scenario that I have upon testing.

1 user connected and querying, saving to database.  I logged in, and after I hit the login this came up on my browser.

Caught .NET exception, source: activevfp_dotnetproxy message: The remote procedure call failed. (Exception from HRESULT: 0x800706BE)

At the same time, the screen in the webserver displays the error box that displaying the comm error.  The first workstaion, on the part that we will save a record on the table, it hangs and throw a bunch of error in its browser. 

Basically at this point after we closed both browser on workstation1 and workstation2, the normal login site does not appear.  It only goes back to normal login site once I clicked the OK button on the error box from the webserver.

Coordinator
Apr 12, 2010 at 7:40 PM
Edited Apr 12, 2010 at 8:25 PM
claudefox wrote:

Does the COM Surrogate pop up an error box on the server and stops the application from working until you close it???

This one addresses that problem:  http://www.whoismadhur.com/2007/05/23/com-surrogate-error-fix/

 

Well there's a lot of stuff out there on the web for this.  Running a vfp mtdll in com+ is pretty much the same as running a vb6 dll the same way

so I'm confident others have fixed this somehow since there were/are so many VB6 users.  Please stay with us and let us know if you fix this - it'll help a lot of others...

 

This one only works I think for an EXE file, if I'm assuming it correct, you basically want me to exclude the activevfp.dll on the DEP right?

XP - http://www.tech-recipes.com/rx/566/xp-sp2-how-to-turn-off-the-data-execution-prevention-feature-dep/

VISTA -http://www.whoismadhur.com/2007/05/23/com-surrogate-error-fix/

 

Coordinator
Apr 12, 2010 at 9:13 PM

I think he actually excluded COM+ for the DEP if you look at his print screens

 

Coordinator
Apr 13, 2010 at 5:12 PM
claudefox wrote:

I think he actually excluded COM+ for the DEP if you look at his print screens

 

Tried this thing again this morning, excluding the dllhost.exe found under Windows\system32 folder, res-tarted the webserver then tested a couple and the error still appears on the webserver.
Coordinator
Apr 13, 2010 at 8:01 PM
Here's another log from the EVENT LOG. Event Type: Error Event Source: Application Error Event Category: None Event ID: 1000 Date: 12/04/2010 Time: 5:05:14 PM User: N/A Computer: WEBSERVER Description: Faulting application dllhost.exe, version 5.1.2600.5512, faulting module vfp9t.dll, version 9.0.0.5721, fault address 0x000e2c41. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. Data: 0000: 41 70 70 6c 69 63 61 74 Applicat 0008: 69 6f 6e 20 46 61 69 6c ion Fail 0010: 75 72 65 20 20 64 6c 6c ure dll 0018: 68 6f 73 74 2e 65 78 65 host.exe 0020: 20 35 2e 31 2e 32 36 30 5.1.260 0028: 30 2e 35 35 31 32 20 69 0.5512 i 0030: 6e 20 76 66 70 39 74 2e n vfp9t. 0038: 64 6c 6c 20 39 2e 30 2e dll 9.0. 0040: 30 2e 35 37 32 31 20 61 0.5721 a 0048: 74 20 6f 66 66 73 65 74 t offset 0050: 20 30 30 30 65 32 63 34 000e2c4 0058: 31 0d 0a 1..
Coordinator
Apr 13, 2010 at 8:29 PM

You might want to try calling from default.asp as opposed to default.aspx .  The best thing to do is try a bunch of things, preferably other solutions you've found thru google.

Coordinator
Apr 15, 2010 at 7:21 PM
claudefox wrote:

You might want to try calling from default.asp as opposed to default.aspx .  The best thing to do is try a bunch of things, preferably other solutions you've found thru google.

Tried the asp instead of the aspx this morning and no error still, here's hoping that if fix it permanently.  Will post back tomorrow or during the weekends if something comes up.

 

Coordinator
Apr 15, 2010 at 9:19 PM
Edited Apr 15, 2010 at 9:20 PM

Cool!  That might even narrow down why it's not working for asp.net...

Coordinator
Apr 21, 2010 at 9:47 PM
Ok, I think we can close this issue now. The following has been tried on the webserver and the last one actually stops the COM Surrogate error. 1. Under the Component Services under the COM+ application level (selecting your COM+ applications of course), play with the setting/properties under Pooling and Recycling. Set a value on Lifetime Limit, Memory Limit, and Expiration Timeout. 2. Set the DEP. In XP, it can be found when you right-click the My Computer then properties to go to the System Properties. Select the Advanced Tab and click on the Settings button under the Performance group. In the performance options, select the Data Execution Prevention tab and choose the TURN ON DEP for all programs and services except those I select. The Add the DLLHOST.EXE under Windows/System32. 3. Change the IIS default document from default.aspx to default.asp. Again the last one stops the whole COM surrogate error on my Web Server. This was tested on an XP Pro with SP3. Thank you Claude for the various ideas/suggestions you posted on this issue. Basically this should summary all those things I have tried until this thing works. =)
Coordinator
Apr 21, 2010 at 11:10 PM

Thanks!  Ok, we know AVFP/COM+ works in ASP as far as getting rid of the COM Surrogate error. 

Now for a fix in ASP.NET, I don't know but it must be related to the differences in the .NET threading architecture or maybe even garbage collection in .NET. 

(One suggestion I found for the garbage collection issue with STA COM in .NET is to use Marshal.ReleaseComObject but I'll leave the testing to someone else

who's really interested in using COM+/AVFP with ASP.NET. )

Coordinator
Sep 9, 2010 at 4:57 PM
Edited Sep 9, 2010 at 4:59 PM

Revisiting this:  ASP.NET appears not to free up resources properly in COM+ with ASP.NET.  You can fix with adjustments to the Application Pool apparently:

"Hi,

We had a big application which contained Classic Asp, many VB6 com components and sql server 2005. It worked without any problems. we decided to migrate our vb6 com components to .NET components (ServicedComponents) (just vb6 components not the classic ASP). It went well without any big problems besides some little code changing, and we tested it in our test environment. but now in production which number of users are more than 80 persons always, we get problems. Sometimes it generates "out of memery exceptions" and system hangs, and sometimes it just crashes without any error messages. We used differnent debugging tools but no success, we cann't find out where in the code it leaks memory or crashes.
we solved our problem very badly(uggly) and it was so, under properties -> pooling tab we increased pool size to 4 and memory limit to 400 Mb and Expiration timeout to 1 minute. now when a pool gets memory problem and memory increases to 400MB it stops and after one menut it begins to be collected and new pool starts to take over.
Our system works but it is not good solution.
what is the problem why the system gets memory problem and why it crashes and what is the solution?
thank you very much..
>>
Maybe you're not cleaning up your unmanaged resources? Can't really help without seeing code and debugging output. windbg and sos are probably going to be your best friends when it comes to figuring this one out.
Reply With Quote

Default


Coordinator
Sep 10, 2010 at 9:26 AM
Edited Sep 10, 2010 at 9:27 AM

I'd really rather not use COM+ at all but it seems to be the only consistent way to do this. 

The other alternative is impersonation in the IIS Application Pool.  I'm trying to get this to work now and would appreciate any

information from those that have attempted this and especially if you got it to work as far as accessing a dbf over the network.

 

other notes:

"A bit more, normally the IUSR_computername user account is local to the webserver and won't even exist on the 2nd machine.

You can clone the account on the target machine, using the same password, and then grant rights to the folder.

Or you can put your IIS under a domain account if you have a domain, but do some research on the pro's & con's of that approach.
__________________
======"

Coordinator
Sep 12, 2010 at 11:40 AM
Edited Sep 12, 2010 at 11:41 AM

Actually, IIS Application Pool Impersonation is the cleanest and therefore preferred way to do Impersonation for Network access to networked DBFs and SQL databases. 

COM+ is an alternative way to do this .