1
votes

I'm developing COM Interoperable classes using Visual Studio 2008. And consuming these classes on Visual FoxPro 9.0 When I compiled the class library it is registering after compilation.

On Visual FoxPro I'm creating object with this code piece on Command window:

newObj = CREATEOBJECT("CemT.Deneme.ClassTest")

When I wanted to chage Class Library on Visual Studio I can't compile and register the dll again. It gives me this error:

Unable to copy file "obj\Debug\clCOMTest.dll" to "bin\Debug\clCOMTest.dll". The process cannot access the file 'bin\Debug\clCOMTest.dll' because it is being used by another process.

With this error I would have to quit VFP and start again. Before creating object I'm compiling the Class Library on Visual Studio. Then I can use the latest version of dll.

This looks very normal because of VFP using the dll but is there any way to do this without restarting VFP?

4
The DLL has a hard lock on it because it was loaded into the FoxPro process. You'd have to convince FoxPro to unload that DLL again. Looking at the docs, you'll at least need RELEASE. How you get it to call CoFreeUnusedLibraries() is anybody's guess. Test your code with a unit test instead.Hans Passant
Unit Test would be good but VFP will call the .NET classes. That's why function calls has different type of parameters. Sometimes passing different type of parameters could be difficult or impossible. RELEASE ALL is making every variable null defined in Command window. But Still I can't compile, it is giving same error.uzay95
@HansPassant: Unit tests are for languages without a decent graphical debugger with edit & continue! (Joke: Unit tests are still good but they are complementary to being able to debug properly).Ben

4 Answers

0
votes

In VFP, have you tried

RELEASE LIBRARY {your dll file}

or, per documentation, you can clear ALL API libraries by

SET LIBRARY TO

(without any specific library name) to clear them

0
votes

Back when I used to do this type of thing (C++ COM components designed for use with VB as the host), I used to set the "Debug" command line to open the correct project in VB.

In other words I was running the VB development environment in the C++ debugger.

This was good because I can still set breakpoints in my DLL and so forth, and work on both the VB and C++ sides simultaneously. (Just remember to press "Save" in VB before you press "Stop" in C++!)

I have never used FoxPro, but you can probably do the same with the -C option:

http://msdn.microsoft.com/en-us/library/bzb50fbk(v=VS.71).aspx

0
votes

It's quite simple, if I understand the issue correctly, in VFP,

Release newObj

0
votes

VFP does not totally release COM objects from memory until the application is closed.

Using the RELEASE command will not release it totally.