I’m using PowerBuilder and usually in C++ I’m using __stdcall as part of the
declaration of functions so I can use the DLL function from PowerBuilder. Can it be done in
C# DLL or what is the equivalent in C# COM?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
ElikPosted Dec 24, 2007, 7:49 PM
I did wrote a callable object from the C# DLL and it with working with my application in visual express C#.
My difficulties are with PowerBuilder since the old know method in PB is calling external function in DLL and PB is built to work with DLL, however ther is another way that you can export web form in PB to .NET assembly which I currently explore.
I still think that ConnectToObject might work since someone on the web did declare that he was able to use C# DLL from PB but did not specify how. I'm sure he did not edit the MSIL directly since he was only familiar with PB, and maybe it is limited but all I need is to launch the invisible window in the DLL and send a click event to the button in the window.
You might ask why all this effort and the reason is there is huge code wrriten in PB and only one fuction that cannot be perform in PB.
Anyway thanks again.
AlanPosted Dec 24, 2007, 11:43 AM
Yes, I think your best bet is to create a COM callable wrapper for your C# dll which can then be consumed from PowerBuilder. If you're not familiar with doing this, there's a good step-by-step article here:
http://www.codeproject.com/KB/COM/nettocom.aspx
The only other way is to use inverse Platform Invoke (i.e. the technique underlying the DllImport attribute in the opposite direction) to expose static C# methods to the unmanaged code. However, this is not supported by C# and so you have to edit the MSIL directly which, whilst not difficult, is messy and so it's seldom used apart from interop with non-COM clients. From what you've said, I don't think it will be suitable for your application but there's an article here if you want to know more:
http://www.csharphelp.com/archives3/archive500.html
ElikPosted Dec 22, 2007, 8:00 PM
I wrote the C# DLL invisble window and I need to control one of the button in the C# DLL invisible window from PowerBuilder application. Any idea how can it be done?
Thank Again.
Elik
AlanPosted Dec 21, 2007, 4:55 AM
If you're using P/Invoke (i.e. DllImport) to call Powerbuilder functions from C#, then the default calling convention is Winapi which (on Windows desktop operating systems) defaults in turn to __stdcall. If you need to use a different calling convention such as cdecl, then there is a field in the DllImport attribute which allows this to be set.
In the case of COM methods, I think I'm right in saying that the COM interop mechanism in .NET (i.e. the Runtime Callable Wrapper) automatically sorts out the correct calling convention.
So, in other words, you shouldn't need to do anything to use __stdcall in your interop calls.