Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
Markdown Monster - The Markdown Editor for Windows

Problems with FoxPro COM Interop on IIS 7 (Vista Beta 2)


:P
On this page:

I was doing some maintenance today on my Web site and noticed that on my local machine I had problems with some Web pages that are using VFP COM components. Since I move between machines a bit these days I had initially forgotten to register the COM components on my local box. Quick fix I thought – but…

 

As it turns out it looks like there are some COM issues in IIS 7 (on Vista Beta 2) that cause at least Visual FoxPro COM objects to fail. I’ve not been able to get these objects to run and even creating the simplest component caused the server to completely crash with a 500 Server error. As soon as a VFP COM object gets instantiated either in ASP.NET or ASP Classic – boom the server crashes completely and only an IIS Reset is getting it back…

 

I spent a bit of time trying to get to the bottom of this but ended up with no luck. It’s not permissions (gave the server full access) and it’s not the COM object itself since the object works fine standalone and even with the VS internal Web Server. Incidentally for ASP.NET at least the workaround for the moment is to use the built in Web Server for development at least as that will properly run the COM object. However, that doesn’t work for ASP classic pages…

 

I also tried sticking the component into COM+ with the same result.

 

I’m just thankful that Web Connection and its internal ISAPI COM manager works on IIS 7 without any problems and I don’t have to come up with a temporary workaround just to run my WWWC applications. I’m sure the above issue will be addressed or may already be fixed in later releases of IIS, but only shows that you can’t take even core functionality like COM access for granted.

 

VFP COM Object in ASP.NET 2.0 Projects

Incidentally I haven’t touched COM and ASP.NET COM components since I’ve worked with ASP.NET 2.0. There are few issues with the new project model and how it handles COM components that is very different than in 1.1. Specifically, I think there are going to be problems for ASP.NET applications that change the VFP COM objects and need to refresh the Interop assembly. In an ASP.NET 1.x project the Interop assembly automatically refreshed itself when the project was recompiled, but this no longer happens in 2.0 stock projects. Stock projects do a one time import and that’s that. You change the COM object, you have to reimport the COM object.This makes and already painful process even more annoying…

 

There’s a workaround for this however: You can create a standard Class Library project and add the reference of the COM object that this project. Class projects still refresh COM objects properly, so when you recompile a class project it tries to pick up the changes in the COM object and updates the Interop assembly. You then add the separate project to your Web project and the Interop assembly comes down with it automatically and now a recompile of either project causes the Interop assembly to be refreshed.

 

When I get some time I should spend a little more time with this to review what has effectively changed. But it’s getting harder and harder to justify any sort of COM interop… <s>


The Voices of Reason


 

Paul Mrozowski
August 03, 2006

# re: Problems with FoxPro COM Interop on IIS 7 (Vista Beta 2)

Have you had any kinds of issue with Intellisense not working with COM components that are part of a ASP.NET project?

I was just working on something today where I added a reference to a VFP COM component to a web application (which drops an interop assembly in to the bin folder). It's actually a bit disconcerting to not have the References folder for web apps anymore.

At any rate, I was expecting Intellisense to kick in as soon as I started typing the COM component name, but it never came up.

I played around with it a bit, wrote code to instanciate my object, set properties, etc. I figured I get a bunch of errors when I compiled it, but it seemed to compile (and work) just fine.

Strange...

scottgu
August 03, 2006

# re: Problems with FoxPro COM Interop on IIS 7 (Vista Beta 2)

Hi Rick,

Can you send me email with more details about the COM issue on IIS7. I can then loop you in with the IIS7 tesam.

Thanks,

Scott

Rick Strahl
August 03, 2006

# re: Problems with FoxPro COM Interop on IIS 7 (Vista Beta 2)

Paul,

I have lots of issues with Intellisense in stock ASP.NET 2.0 projects period <s>. Like I said above the references to a COM object don't refresh, but Intellisense should work as long as you have the Interop assembly. The assembly is just like any other assembly as far as IS is concerned.

That said, most of the problems I have with IS in 2.0 projects is that for some reason the project doesn't refresh. Sometimes a full recompile fixes the problem - other times it doesn't. I haven't use COM at all from 2.0 projects up to now, and in this project the Interop assembly shows up fine in Intellisense.

Rick Strahl
August 03, 2006

# re: Problems with FoxPro COM Interop on IIS 7 (Vista Beta 2)

Scott - done...

Paul Mrozowski
August 04, 2006

# re: Problems with FoxPro COM Interop on IIS 7 (Vista Beta 2)

I was calling this COM object via a class wrapper to start it up in it's own thread (and pass in a bunch of parameters). After I moved the class into it's own file, intellisense for the COM object started working (shrug - not sure why that makes a difference).

Mahmoud Fayed
October 27, 2006

# re: Problems with FoxPro COM Interop on IIS 7 (Vista Beta 2)

i have strange problem , i use ASP.NET (VS 2005,.NET Framework 2.0) i have my own web page which call VFP COM(Multi Threaded DLL) and when i test the page in the interneal web browser of the .NET (using Ctrl+F5) every thing runs OK, but when i set my deafult web site to use my web page (After publishing it) i have error (COM Class Factory ERROR)
my platfrom is Windows XP SP2 , i don't know why ? the web page work in my test to it through the .Net FRAMEWORK and does not work in the normal web browser through (Localhost) (THE ERROR ONLY APPEARS WHEN CALLING THE COM OBJECT)
i am not sure that my problem is the same as the problem stated here
any one can help ?

Rick Strahl
October 27, 2006

# re: Problems with FoxPro COM Interop on IIS 7 (Vista Beta 2)

Mahmoud, it's a permission problem. Running under the built-in Web Server uses your current logged on user account. Running under IIS uses the Web Server's user account which probably doesn't have access to your COM object or your data.

There are several ways to deal with that - assigning the appropriate rights to your COM DLL and your data files, or using COM+ to host your DLL and set the Impersonation on the COM+ package to a specific account that has rights to DLL and data.

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024