473,804 Members | 3,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COM Object setting a property problem

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.DataReco rdset

set iDRS = ConnectedServer .Data.NewRecord set

With iDRS
.Criteria.Filte rTagSet = True
.Criteria.Filte rTag = fullTagName
End with
In C#

iH_SDK.DataReco rdset iDRS = ConnectedServer .Data.NewRecord set();

iDRS.Criteria.F ilterTagsSet = true;

iDRS.Criteria.F ilterTag = 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._DataCr ieteria.get_Fil terTag()' or
'iH_SDK._DataCr iteria.set_Filt erTag(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
6 3921
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******** ******@tk2msftn gp13.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.DataReco rdset

set iDRS = ConnectedServer .Data.NewRecord set

With iDRS
.Criteria.Filte rTagSet = True
.Criteria.Filte rTag = fullTagName
End with
In C#

iH_SDK.DataReco rdset iDRS = ConnectedServer .Data.NewRecord set();

iDRS.Criteria.F ilterTagsSet = true;

iDRS.Criteria.F ilterTag = 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._DataCr ieteria.get_Fil terTag()' or
'iH_SDK._DataCr iteria.set_Filt erTag(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
But it looks like the reference to the string object must be passed by
reference:
'iH_SDK._DataCr iteria.set_Filt erTag(ref string)'
Don't know why this is the case-- but did you *try* using the above line
instead i.e.:

iH_SDK._DataCri teria.set_Filte rTag(ref fullTagName)

If so what was the result?

S.

"Andrew Mueller" <am******@ins3. com> wrote in message
news:eW******** ******@TK2MSFTN GP10.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******** ******@tk2msftn gp13.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.DataReco rdset

set iDRS = ConnectedServer .Data.NewRecord set

With iDRS
.Criteria.Filte rTagSet = True
.Criteria.Filte rTag = fullTagName
End with
In C#

iH_SDK.DataReco rdset iDRS = ConnectedServer .Data.NewRecord set();

iDRS.Criteria.F ilterTagsSet = true;

iDRS.Criteria.F ilterTag = 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._DataCr ieteria.get_Fil terTag()' or
'iH_SDK._DataCr iteria.set_Filt erTag(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
I have tried that, but I got the error:

An object reference is required for the nonstatic field, method, or
property 'iH_SDK._DataCr iteria.set_Filt erTag(ref string)'

I believe this is mainly because I have not created an object
iH_SDK._DataCri teria. 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._DataCri teria 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@wer ts> wrote in message
news:uS******** *****@tk2msftng p13.phx.gbl...
But it looks like the reference to the string object must be passed by
reference:
'iH_SDK._DataCr iteria.set_Filt erTag(ref string)'
Don't know why this is the case-- but did you *try* using the above line
instead i.e.:

iH_SDK._DataCri teria.set_Filte rTag(ref fullTagName)

If so what was the result?

S.

"Andrew Mueller" <am******@ins3. com> wrote in message
news:eW******** ******@TK2MSFTN GP10.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******** ******@tk2msftn gp13.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.DataReco rdset

set iDRS = ConnectedServer .Data.NewRecord set

With iDRS
.Criteria.Filte rTagSet = True
.Criteria.Filte rTag = fullTagName
End with
In C#

iH_SDK.DataReco rdset iDRS = ConnectedServer .Data.NewRecord set();

iDRS.Criteria.F ilterTagsSet = true;

iDRS.Criteria.F ilterTag = 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._DataCr ieteria.get_Fil terTag()' or
'iH_SDK._DataCr iteria.set_Filt erTag(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
Andrew,
iDRS.Criteria.F ilterTag = fullTagName;


Make that

iDRS.Criteria.s et_FilterTag(re f fullTagName);


Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 13 '05 #5
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.s et_SamplingMode (ref intSM);

ERROR:

The best overloaded method match for
'iH_SDK._DataCr iteria.set_Samp lingMode(ref iH_SDK.ihSampli ngMode)' has some
invalid arguments.
Thanks again!

Andrew Mueller
"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:uc******** ******@TK2MSFTN GP12.phx.gbl...
Andrew,
iDRS.Criteria.F ilterTag = fullTagName;


Make that

iDRS.Criteria.s et_FilterTag(re f fullTagName);


Mattias

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

Nov 13 '05 #6
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.s et_SamplingMode (ref intSM);

ERROR:

The best overloaded method match for
'iH_SDK._DataC riteria.set_Sam plingMode(ref iH_SDK.ihSampli ngMode)' 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
3054
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of a single collections type, I should be proposing a new "namespaces" module instead. Some of my reasons: (1) Namespace is feeling less and less like a collection to me. Even though it's still intended as a data-only structure, the use cases...
4
7000
by: Ralph?? | last post by:
I'm trying to use object pointers to access/modify various properties of various layers. The problem i'm having is that pointers created within my functions dont have world scope even though the variables used are world variables. Script Example: <script> var lyr1, lyr2; function initIE(){ lyr1 = layer1.style;
6
1519
by: Steve Neill | last post by:
Here's an intersting problem... I have a JS object that has a property: "fullname"... myObject.client.name.fullname = "John Smith"; I also have a corresponding DOM element with an "id" value set to "client_name_fullname": <input type="text" id="client_name_fullname">
2
2860
by: onedaywhen | last post by:
Does anyone know of a good .NET article, sample, etc to demonstrate creating an object model, one where you have one externally creatable object with a hierarchy of dependent objects? For example, the only way to create a new Spoke object is to first create a new Bicycle object, add to its Wheel collection then add to its Spoke collection. Here's a good article for doing this in VB6: ...
3
2234
by: BakelNB | last post by:
I am new to the .Net environment, so please bear with me. I am passing a form object (e.g. formA) to an existing form (e.g. formB) by setting a property value defined in formB to hold the formA object. Please keep in mind that formB is defined in a separate library project. I then display formB. Once formB is displayed, I have code in a double click event procedure in formB to display formA by getting the form object throught the property...
4
3527
by: Anthony England | last post by:
This is a simple question, which has been debated before, but can I ask it again with reference to a specific example? The question is basically should I close and set to nothing an ADO connection object? Normally, I would do this and not worry about whether I could have chosen not to bother. However, in this example, setting the variable to nothing can take ages, up to 15 seconds, and I wonder whether it is worth it. I would like a...
6
6360
by: TJO | last post by:
Below is some sample code that fades div tags that is not working in IE 6.0.29 on xp sp2. Can anyone help see why the if(ie5) document.getElementById(divID).filters.alpha.opacity lines are not working ? I cannot find a solution yet. THanks <script type="text/javascript" language=javascript> var ie5 = (document.all && document.getElementById); var ns6 = (!document.all && document.getElementById);
9
4695
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate> /asp:Repeater> The DataSource for this Repeater is a CollectionBase of objects and is
3
1464
by: Patient Guy | last post by:
Subject line would seem to say it all: How does one trigger the execution of a method within an object or any other code/function with the setting of an object property? More elaboration for those who want it: Suppose we have anObjectType, with a property .description, whose value can be a string, and the value of .description actually describes the
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10571
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.