Click here to Skip to main content
15,886,761 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ,

i am having [in,out,size_is(Size)] byte compress_page[*] parameter in my idl file. now we are migrating to wcf.
can you please tell me know how we convert into C#.
for ex:

see this function in IDL file
C++
long RMTReadMultiPages(  [in] File fh,
                      [in, string] char prj[],
                      [in] long fileno,
                      [in] long extno,
                      [in] long pageStart,
                      [in,out] long *numPages,
                      [in] long transferSize,
                      [out] short *failCode,
                      [in,out,size_is(Size)] byte compress_page[*]
                     );


i have to write this function in C#.

CSS
I am trying to host my Wcf service with Entlib 5.0 Validation. When servie operation contracts go for validation they get crash. Whiel investigating, I found that ref keyword in Wcf service's operation giving this problem. E.g.:

Operation contract in service is like:

public void GetData(int ID, string name, ref string location) {};

Now, while validating string location, it gets crash and if I remove ref keyword it works fine.

Though, in EntLib version 4.0 there are no such issues.
i tried replacing "ref" with "out" the issue was solved..
that ref replacing with out means [in, out] replaced with out.. i am getting some junk values in "compress_page", i am suspecting that this because of When it acts as an input it taking junk values.



Thanks f
or advance for your coperation
Posted
Updated 30-Oct-14 23:20pm
v4
Comments
Richard MacCutchan 30-Oct-14 10:08am    
The definition above gives you all the parameters and their types, what is the problem you are having?
shiva_VC++ 31-Oct-14 5:18am    
I am trying to host my Wcf service with Entlib 5.0 Validation. When servie operation contracts go for validation they get crash. Whiel investigating, I found that ref keyword in Wcf service's operation giving this problem. E.g.:

Operation contract in service is like:

public void GetData(int ID, string name, ref string location) {};

Now, while validating string location, it gets crash and if I remove ref keyword it works fine.

Though, in EntLib version 4.0 there are no such issues.
i tried replacing "ref" with "out" the issue was solved..
that ref replacing with out means [in, out] replaced with out.. i am getting some junk values in "compress_page", i am suspecting that this because of When it acts as an input it taking junk values.

1 solution

This list might give you some help.
Platform Invoke Data Types[^]

[in] can be removed
[out] corresponds to out
[in,out] can be replaced by ref


Here is an overview over IDL Understanding Interface Definition Language[^]

The Marshal Class[^] might be of help too.

Here is a Wiki page about PInvoke. http://en.wikipedia.org/wiki/Platform_Invocation_Services[^]
PInvoke.net[^] can be good to use as a reference. (However, I cannot access the site at the moment)

Maybe this question at StackOverflow will give some clues: Convert Interface IDL file to C#[^]

Or this CP article: Essential P/Invoke[^]
 
Share this answer
 
v3
Comments
shiva_VC++ 31-Oct-14 0:21am    
thanks for your help,

the problem with ref key word . presently we are using Microsoft Enterprise library Version 4.0 we had thought to Migrate to MSE 5.0 .
I am trying to host my Wcf service with Entlib 5.0 Validation. When servie operation contracts go for validation they get crash. Whiel investigating, I found that ref keyword in Wcf service's operation giving this problem. E.g.:

Operation contract in service is like:

public void GetData(int ID, string name, ref string location) {}; [here ref in place of [in , out] in IDL file ]

Now, while validating string location, it gets crash and if I remove ref keyword it works fine.

Though, in EntLib version 4.0 there are no such issues.
George Jonsson 31-Oct-14 4:03am    
Don't use ref and string, use StringBuilDer instead. And don't
forget to initialize with a length.
shiva_VC++ 31-Oct-14 5:23am    
please give some example it is very help full to me,

thank you very much for this help
shiva_VC++ 31-Oct-14 5:30am    
i have same problem with Byte, int also
like in above function
[in,out,size_is(Size)] byte compress_page[*] it will becomes
ref byte compress_page[].

here also "ref" causing the problem


George Jonsson 31-Oct-14 7:39am    
For arrays you can try IntPtr (without ref).
Look at www.pinvoke.net for many examples of Win32 method signatures to c#

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900