on 03-30-2016 9:18 PM
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.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I usally use:
lole_X.DisconnectObject()
destroy lole_X
GarbageCollect()
Bernhard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does ConnectToObject ( ) work? Rather than connect to new. I seem to recall something from five years ago...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.