cancel
Showing results for 
Search instead for 
Did you mean: 

Working with COM in PB

Former Member
0 Kudos

Hello All,

I have created a COM wrapper dll for a webservice using C# which I want to call from PB (12.5.2 5609). My problem is that PB does not release the object after code has executed. Any ideas what am I doing wrong?

Here is my pb code:

Integer Rtn

OleObject oWS

oWS = CREATE OLEObject

Rtn = oWS.ConnectToNewObject ("myWS.class1") // Returns 0 = Success

Rtn = oWS.ProcessA () // Returns success

Rtn = oWS.DisconnectObject () // Returns 0 = Success

DESTROY oWS

The DisconnectObject returns 0 but the object is still in memory.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I use ConnectToNewObject and DisconnectObject followed by a Destroy. However I have noticed that if I am running my application from the PB IDE it keeps the dll in memory, so I can't replace the dll with a new one until I exit from the IDE, whereas this isn't as issue on a built application.

Also, my ,NET cCOM wrapper objects are either registered in the registry or I uses side-by-side dlls with manifest files. Not sure how you are accessing yours?

Former Member
0 Kudos

Within the IDE the DLL is kept in memory because the calling process (IDE) is still running. So far ok.

I use to registrate the COM DLLs in the registry.

Bernhard

Former Member
0 Kudos

How do you determine the dll has not been released? I can write a quick test here and see if I can spot anythign.

Former Member
0 Kudos

With installation I copy all necessary DLLs to their locations. Then I try to ConnectToNewObject( "RapidData.RDComCtrl" ). If it fails I create a temporary REG-File with all necessary informations and execute REGEDIT.

Bernhard

Former Member
0 Kudos

Sorry for being stupid but I don't understand. Why would it fail to Connect, why are you creating a temporary reg file instead of using regasm?

Here's what I do after each build of the dll in Visual Studio in the post-build event:

"$(ProjectDir)Libraries\genman32" "$(TargetDir)$(TargetFileName)" /out:"$(TargetDir)temp.man"

"$(ProjectDir)Libraries\genman32" "$(TargetDir)$(TargetFileName)" /add /manifest:"$(TargetDir)temp.man"

"$(ProjectDir)Libraries\regasm32" /tlb:"$(TargetDir)$(TargetName).tlb" /codebase  "$(TargetDir)$(TargetFileName)"

The first block uses genman32, a third-party tool to create and embed the correct manifest file into the dll. I have a feeling you only need this if youa re using side-by-side dlls. The second block registers the dll as a COM object into the registry ready for ConnectToNewObject to find it.

Let me know if you'd like genman32, I'd need to know the version of .NET you are using.

Once Appeon get a code library up and running I'll post it there.

Former Member
0 Kudos

I think your connect fails because your class is not registrated correctly. See HKCR\<YourClass>.

When I generate my .NET DLLs, I get a REG file. For first time registration in my application I read that REG file, copy it to a new temporary file, modify that file (CodeBase) to meet the right folder and run REGEDIT32 with that temporary file.

Bernhard

Former Member
0 Kudos

I am running my app from the PB IDE. Good to know that it is not something I am doing wrong.

Thanks Aron.

Answers (3)

Answers (3)

Former Member
0 Kudos

If it is COM collable wrapper class then you have to bind the dll using RegAsm, After bind the dll you can use the dll using Ole client.

Thanks

Avishek

Former Member
0 Kudos

I usally use:

lole_X.DisconnectObject()

destroy lole_X

GarbageCollect()

Bernhard

Former Member
0 Kudos

Does ConnectToObject ( ) work? Rather than connect to new. I seem to recall something from five years ago...