T
TJ
In C# how do you achieve pass-by-reference property declarations in the Type
Library?
I am writing a COM Class Library that must mimick an existing library for
which the only information is the TypeLib. I'm using Visual Studio .NET
2003.
The original library provides simple authentication services, from Access
and MS-SQL OLEDB providers. The enhancement I'm creating provides support
for ODBC and will be a drop-in replacement.
The original library was written in Visual Basic 6, and declares an
interface with property setter methods that take pointers as arguments, as
this extract shows:
dispinterface _DBLink {
methods:
[id(0x60030006)] VARIANT_BOOL CheckUser([in, out] BSTR* User, [in, out]
BSTR* Password);
[id(0x68030008), propput] void LoginClassField([in, out] BSTR* rhs);
I've created an identical COM Class Library in C#, but the arguments to the
property setter methods are passed-by-value, and it isn't possible to use
the C# "ref" or "out" modifier on Properties.
dispinterface _DBLink {
methods:
[id(0x60020006)] VARIANT_BOOL CheckUser([in, out] BSTR* User, [in, out]
BSTR* Password);
[id(0x60020008), propput] void LoginClassField([in] BSTR rhs);
[id(0x60020009)] void set_LoginClassField([in, out] BSTR* value);
code:
public interface _DBLink {
bool CheckUser(ref string User, ref string Password);
string LoginPassField { set; }
void set_LoginClassField(ref string value);
// ... rest of code
}
As you can see, although I can define the Property setters as methods, the
TypeLib would then no longer declare them as "propput".
Any ideas?
TJ.
Library?
I am writing a COM Class Library that must mimick an existing library for
which the only information is the TypeLib. I'm using Visual Studio .NET
2003.
The original library provides simple authentication services, from Access
and MS-SQL OLEDB providers. The enhancement I'm creating provides support
for ODBC and will be a drop-in replacement.
The original library was written in Visual Basic 6, and declares an
interface with property setter methods that take pointers as arguments, as
this extract shows:
dispinterface _DBLink {
methods:
[id(0x60030006)] VARIANT_BOOL CheckUser([in, out] BSTR* User, [in, out]
BSTR* Password);
[id(0x68030008), propput] void LoginClassField([in, out] BSTR* rhs);
I've created an identical COM Class Library in C#, but the arguments to the
property setter methods are passed-by-value, and it isn't possible to use
the C# "ref" or "out" modifier on Properties.
dispinterface _DBLink {
methods:
[id(0x60020006)] VARIANT_BOOL CheckUser([in, out] BSTR* User, [in, out]
BSTR* Password);
[id(0x60020008), propput] void LoginClassField([in] BSTR rhs);
[id(0x60020009)] void set_LoginClassField([in, out] BSTR* value);
code:
public interface _DBLink {
bool CheckUser(ref string User, ref string Password);
string LoginPassField { set; }
void set_LoginClassField(ref string value);
// ... rest of code
}
As you can see, although I can define the Property setters as methods, the
TypeLib would then no longer declare them as "propput".
Any ideas?
TJ.