How to change [propputref] to [propput]

O

oleg

Hello!

I developed COM Type Library in C#! This Com used by VB6.0,
but when from vb called some property of com object ,happen error "Object
required"!!!
Part of C# COM:
public object xxx
{
get
{
return 2;
}
set
{
qq=2;
}
}
generated .tlb file:
[id(0x6002000d), propget]// for get
VARIANT xxx();
[id(0x6002000d), propputref]// for set
void xxx([in] VARIANT rhs);
I think, problem in propputref attribute! Which attribute i need to set in
C# code to change [propputref] to [propput] ??

thanks for help
 
N

Nicholas Paldino [.NET/C# MVP]

Oleg,

Unfortunately, you can't place an attribute in C# (from what I can tell,
I've tried to work around this before). What you can do is use a tool like
OLE View on the TLB that is exported, getting the IDL. Then, copy that and
paste it into a new file. Once you have that, change the property
accordingly (the attribute on the property, that is), and then compile using
IDL compiler (MIDL).

Hope this helps.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Oleg,
public object xxx

should be changed to

public int xxx.

"object" is a reference type and thus causes the [propputref] attribute to
be exported to the type library. "int", on the other hand, is a value type
and should be therefore passed by value.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

oleg said:
Hello!

I developed COM Type Library in C#! This Com used by VB6.0,
but when from vb called some property of com object ,happen error "Object
required"!!!
Part of C# COM:
public object xxx
{
get
{
return 2;
}
set
{
qq=2;
}
}
generated .tlb file:
[id(0x6002000d), propget]// for get
VARIANT xxx();
[id(0x6002000d), propputref]// for set
void xxx([in] VARIANT rhs);
I think, problem in propputref attribute! Which attribute i need to set in
C# code to change [propputref] to [propput] ??

thanks for help
 
O

oleg

Thanks!!!

But I need exectly public object xxx!!

Dmitriy Lapshin said:
Hi Oleg,
public object xxx

should be changed to

public int xxx.

"object" is a reference type and thus causes the [propputref] attribute to
be exported to the type library. "int", on the other hand, is a value type
and should be therefore passed by value.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

oleg said:
Hello!

I developed COM Type Library in C#! This Com used by VB6.0,
but when from vb called some property of com object ,happen error "Object
required"!!!
Part of C# COM:
public object xxx
{
get
{
return 2;
}
set
{
qq=2;
}
}
generated .tlb file:
[id(0x6002000d), propget]// for get
VARIANT xxx();
[id(0x6002000d), propputref]// for set
void xxx([in] VARIANT rhs);
I think, problem in propputref attribute! Which attribute i need to set in
C# code to change [propputref] to [propput] ??

thanks for help
 
O

oleg

ðÏÈÏÖÅ ÔÙ ÔÏÖÅ ÉÚ òÏÓÓÉÉ!!!
óÐÁÓÉÂÏ ÚÁ ÓÏ×ÅÔ!!!!
Dmitriy Lapshin said:
Hi Oleg,
public object xxx

should be changed to

public int xxx.

"object" is a reference type and thus causes the [propputref] attribute to
be exported to the type library. "int", on the other hand, is a value type
and should be therefore passed by value.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

oleg said:
Hello!

I developed COM Type Library in C#! This Com used by VB6.0,
but when from vb called some property of com object ,happen error "Object
required"!!!
Part of C# COM:
public object xxx
{
get
{
return 2;
}
set
{
qq=2;
}
}
generated .tlb file:
[id(0x6002000d), propget]// for get
VARIANT xxx();
[id(0x6002000d), propputref]// for set
void xxx([in] VARIANT rhs);
I think, problem in propputref attribute! Which attribute i need to set in
C# code to change [propputref] to [propput] ??

thanks for help
 
D

Dmitriy Lapshin [C# / .NET MVP]

Oleg,

I'm from Ukraine actually, and speaking Russian won't be appreciated in this
international newsgroup. May I ask why would you need a property of type
object? Probably we are solving the consequence instead of the reason?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

oleg said:
Thanks!!!

But I need exectly public object xxx!!

Dmitriy Lapshin said:
Hi Oleg,
public object xxx

should be changed to

public int xxx.

"object" is a reference type and thus causes the [propputref] attribute to
be exported to the type library. "int", on the other hand, is a value type
and should be therefore passed by value.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

oleg said:
Hello!

I developed COM Type Library in C#! This Com used by VB6.0,
but when from vb called some property of com object ,happen error "Object
required"!!!
Part of C# COM:
public object xxx
{
get
{
return 2;
}
set
{
qq=2;
}
}
generated .tlb file:
[id(0x6002000d), propget]// for get
VARIANT xxx();
[id(0x6002000d), propputref]// for set
void xxx([in] VARIANT rhs);
I think, problem in propputref attribute! Which attribute i need to
set
in
C# code to change [propputref] to [propput] ??

thanks for help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top