By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,668 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,668 IT Pros & Developers. It's quick & easy.

COM Object setting a property problem

P: n/a
Hello all,

I am working on a project, converting code from VB 6.0 to C#. I have a
COM object (SDK.dll) referenced and am having some issues using it. I don't
think it is specific to the object as much as it is specific to how either
C# or the CLR allows the use of different parameters and variables... This
is just a guess. Anyway, here is the problem:
In VB:

Dim iDRS as iH_SDK.DataRecordset

set iDRS = ConnectedServer.Data.NewRecordset

With iDRS
.Criteria.FilterTagSet = True
.Criteria.FilterTag = fullTagName
End with
In C#

iH_SDK.DataRecordset iDRS = ConnectedServer.Data.NewRecordset();

iDRS.Criteria.FilterTagsSet = true;

iDRS.Criteria.FilterTag = fullTagName;
--> On the last line in the C# program, I get a compile error of:

Property, indexer, or event 'FilterTag' is not supported by the
language; try directly calling accessor methods
'IH_SDK._DataCrieteria.get_FilterTag()' or
'iH_SDK._DataCriteria.set_FilterTag(ref string)'
Any idea what I am doing wrong? I have tried a whole bunch of stuff without
a solution yet and I am at the end of my long rope.

Thanks in advance!!

Andrew Mueller

Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Looking even furthur into it.....

The FilterTagSet is a property of the Criteria object of type Boolean.... It
works fine and can be set without issue.

The FilterTag is a property of the Criteria object of type String....
doesn't work fine.

Is this a COM / interop issue??? How do I get around it??

"Andrew Mueller" <am******@ins3.com> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
Hello all,

I am working on a project, converting code from VB 6.0 to C#. I have a COM object (SDK.dll) referenced and am having some issues using it. I don't think it is specific to the object as much as it is specific to how either
C# or the CLR allows the use of different parameters and variables... This
is just a guess. Anyway, here is the problem:
In VB:

Dim iDRS as iH_SDK.DataRecordset

set iDRS = ConnectedServer.Data.NewRecordset

With iDRS
.Criteria.FilterTagSet = True
.Criteria.FilterTag = fullTagName
End with
In C#

iH_SDK.DataRecordset iDRS = ConnectedServer.Data.NewRecordset();

iDRS.Criteria.FilterTagsSet = true;

iDRS.Criteria.FilterTag = fullTagName;
--> On the last line in the C# program, I get a compile error of:

Property, indexer, or event 'FilterTag' is not supported by the
language; try directly calling accessor methods
'IH_SDK._DataCrieteria.get_FilterTag()' or
'iH_SDK._DataCriteria.set_FilterTag(ref string)'
Any idea what I am doing wrong? I have tried a whole bunch of stuff without a solution yet and I am at the end of my long rope.

Thanks in advance!!

Andrew Mueller

Nov 13 '05 #2

P: n/a
But it looks like the reference to the string object must be passed by
reference:
'iH_SDK._DataCriteria.set_FilterTag(ref string)'
Don't know why this is the case-- but did you *try* using the above line
instead i.e.:

iH_SDK._DataCriteria.set_FilterTag(ref fullTagName)

If so what was the result?

S.

"Andrew Mueller" <am******@ins3.com> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl...
Looking even furthur into it.....

The FilterTagSet is a property of the Criteria object of type Boolean.... It works fine and can be set without issue.

The FilterTag is a property of the Criteria object of type String....
doesn't work fine.

Is this a COM / interop issue??? How do I get around it??

"Andrew Mueller" <am******@ins3.com> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
Hello all,

I am working on a project, converting code from VB 6.0 to C#. I
have a
COM object (SDK.dll) referenced and am having some issues using it. I

don't
think it is specific to the object as much as it is specific to how

either C# or the CLR allows the use of different parameters and variables... This is just a guess. Anyway, here is the problem:
In VB:

Dim iDRS as iH_SDK.DataRecordset

set iDRS = ConnectedServer.Data.NewRecordset

With iDRS
.Criteria.FilterTagSet = True
.Criteria.FilterTag = fullTagName
End with
In C#

iH_SDK.DataRecordset iDRS = ConnectedServer.Data.NewRecordset();

iDRS.Criteria.FilterTagsSet = true;

iDRS.Criteria.FilterTag = fullTagName;
--> On the last line in the C# program, I get a compile error of:

Property, indexer, or event 'FilterTag' is not supported by the
language; try directly calling accessor methods
'IH_SDK._DataCrieteria.get_FilterTag()' or
'iH_SDK._DataCriteria.set_FilterTag(ref string)'
Any idea what I am doing wrong? I have tried a whole bunch of stuff

without
a solution yet and I am at the end of my long rope.

Thanks in advance!!

Andrew Mueller


Nov 13 '05 #3

P: n/a
I have tried that, but I got the error:

An object reference is required for the nonstatic field, method, or
property 'iH_SDK._DataCriteria.set_FilterTag(ref string)'

I believe this is mainly because I have not created an object
iH_SDK._DataCriteria. The reason I did not create this object is because
the iDRS points to a specific instance of a RecordSet object and the
iH_SDK._DataCriteria would be pointing to a generic one.

That is why I have been trying to set that property directly, as I would
thing would make sense. It is very easy to do this in VB 6.0. I would
think that it would not be this difficult. There must be some way to set
that property if I can set the other property.

Andy
"Simon Trew" <ten.egnaro@werts> wrote in message
news:uS*************@tk2msftngp13.phx.gbl...
But it looks like the reference to the string object must be passed by
reference:
'iH_SDK._DataCriteria.set_FilterTag(ref string)'
Don't know why this is the case-- but did you *try* using the above line
instead i.e.:

iH_SDK._DataCriteria.set_FilterTag(ref fullTagName)

If so what was the result?

S.

"Andrew Mueller" <am******@ins3.com> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl...
Looking even furthur into it.....

The FilterTagSet is a property of the Criteria object of type
Boolean.... It
works fine and can be set without issue.

The FilterTag is a property of the Criteria object of type String....
doesn't work fine.

Is this a COM / interop issue??? How do I get around it??

"Andrew Mueller" <am******@ins3.com> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
Hello all,

I am working on a project, converting code from VB 6.0 to C#. I

have
a
COM object (SDK.dll) referenced and am having some issues using it. I

don't
think it is specific to the object as much as it is specific to how

either C# or the CLR allows the use of different parameters and variables... This is just a guess. Anyway, here is the problem:
In VB:

Dim iDRS as iH_SDK.DataRecordset

set iDRS = ConnectedServer.Data.NewRecordset

With iDRS
.Criteria.FilterTagSet = True
.Criteria.FilterTag = fullTagName
End with
In C#

iH_SDK.DataRecordset iDRS = ConnectedServer.Data.NewRecordset();

iDRS.Criteria.FilterTagsSet = true;

iDRS.Criteria.FilterTag = fullTagName;
--> On the last line in the C# program, I get a compile error of:

Property, indexer, or event 'FilterTag' is not supported by the
language; try directly calling accessor methods
'IH_SDK._DataCrieteria.get_FilterTag()' or
'iH_SDK._DataCriteria.set_FilterTag(ref string)'
Any idea what I am doing wrong? I have tried a whole bunch of stuff

without
a solution yet and I am at the end of my long rope.

Thanks in advance!!

Andrew Mueller



Nov 13 '05 #4

P: n/a
Andrew,
iDRS.Criteria.FilterTag = fullTagName;


Make that

iDRS.Criteria.set_FilterTag(ref fullTagName);


Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 13 '05 #5

P: n/a
That works great! Thanks....

Here is another one, though... And, if you can, could you explain what
interop (If that is what changes things) is doing so that I can understand
why I am doing this??

I have another property of the criteria object called SamplingMode. This
one is of type ihSamplingMode where:

ihSamplingMode contains Calculated, CurrentValue, Interpolated, etc...

Ultimately:
Calculated = 6, CurrentValue = 1, Interpolated = 2 from an enumerated
type.
How do I set these properties? I have tried the same idea, but it doesn't
like that.

TRIED:

int intSM = 1;

iDRS.Criteria.set_SamplingMode(ref intSM);

ERROR:

The best overloaded method match for
'iH_SDK._DataCriteria.set_SamplingMode(ref iH_SDK.ihSamplingMode)' has some
invalid arguments.
Thanks again!

Andrew Mueller
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uc**************@TK2MSFTNGP12.phx.gbl...
Andrew,
iDRS.Criteria.FilterTag = fullTagName;


Make that

iDRS.Criteria.set_FilterTag(ref fullTagName);


Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Nov 13 '05 #6

P: n/a
Andrew,
Here is another one, though... And, if you can, could you explain what
interop (If that is what changes things) is doing so that I can understand
why I am doing this??
The previous issue was due to the fact that C# only supports indexed
(or parameterized) properties where the index arguments are passed by
value. In COM, it was possible (and not uncommon) to pass them by
reference instead. For such properties, you can't use the regular
property syntax in C#, but must explicitly call the underlying set_
method instead.

This new problem seems to be a simple use of the wrong type, and not
really interop related.

int intSM = 1;

iDRS.Criteria.set_SamplingMode(ref intSM);

ERROR:

The best overloaded method match for
'iH_SDK._DataCriteria.set_SamplingMode(ref iH_SDK.ihSamplingMode)' has some
invalid arguments.


Since the method parameter apparently is of type ihSamplingMode, so
should your local variable be. Using an int wont work. So change it to

ihSamplingMode intSM = ihSamplingMode.CurrentValue;

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.