473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Is there anything special I need to do in c# to make my code com compatible

The reason I ask this is because I'm having problems accessing an array of
type TrackSelection in a VBS script I'm using to test my code.

item.AdditionalInformation returns an array of type TrackSelection. I don't
know what I'm doing wrong. All the classes (that I need for COM) seem to
follow the requirements for COM interop.

Code for Item -> http://www.skidmore.edu/~h_blackw/Item.cs
Code for TrackSelection ->
http://www.skidmore.edu/~h_blackw/TrackSelection.cs

******CODE******

Set comObj = CreateObject("iCode.Interop.ComInterop")
Set item = comObj.ItemFromItemCode("KV35S42")
Set tracks = item.AdditionalInformation

******Error*****

Windows Script Host
Line: 3
Char: 1
Error: Object required
Code: 800A01A8
Source: Microsoft VBScript runtime error
I've been fooling around with this for the last 5 hrs or so, any help will
be appreciated!!!!
Nov 15 '05 #1
8 1574
a good read would be MSDN's c# tutorials. There's two there to do with
interop that'll solve what you're trying to do.

vbscript is trying to access an unmanaged COM object, but your c#
compilation is .NET...
you need to use the regasm command line tool (with .net) to create a bridge
layer, allowing "unsafe" clients to communicate with the .net DLL.

good luck!
Dan.

"Hasani" <bi*******@hax0r.dyndns.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
The reason I ask this is because I'm having problems accessing an array of
type TrackSelection in a VBS script I'm using to test my code.

item.AdditionalInformation returns an array of type TrackSelection. I don't
know what I'm doing wrong. All the classes (that I need for COM) seem to
follow the requirements for COM interop.

Code for Item -> http://www.skidmore.edu/~h_blackw/Item.cs
Code for TrackSelection ->
http://www.skidmore.edu/~h_blackw/TrackSelection.cs

******CODE******

Set comObj = CreateObject("iCode.Interop.ComInterop")
Set item = comObj.ItemFromItemCode("KV35S42")
Set tracks = item.AdditionalInformation

******Error*****

Windows Script Host
Line: 3
Char: 1
Error: Object required
Code: 800A01A8
Source: Microsoft VBScript runtime error
I've been fooling around with this for the last 5 hrs or so, any help will
be appreciated!!!!

Nov 15 '05 #2
check out the Interop tutorials on this page.

http://msdn.microsoft.com/library/de...pTutorials.asp
Nov 15 '05 #3
well, while I read the stuff in the link (which is a lot)
can you at least tell me how I can return objects derived from System.Array
to COM or how to return an ArrayList to COM?
"Daniel Bass" <I'm really @ sick of spam> wrote in message
news:OT*************@TK2MSFTNGP09.phx.gbl...
check out the Interop tutorials on this page.

http://msdn.microsoft.com/library/de...pTutorials.asp

Nov 15 '05 #4
That there is I suppose, but the question you posed doesn't warrant a short
solution, from the stand point it would be more beneficial to understand
more about what you're trying to do.

With regards your arraylist question, I'm unaware of an ArrayList structure
existing outside the .Net framework? This means what would be required is a
conversion to a more generic (or unmanaged) state. Rather than passing out a
defined .Net structure. So ArrayList myArray would be better as Int[1024]
aryintMyArray.

I don't really understand all the in's and out's of it all, but found the
submitted articule useful in providing the info required to accomplish what
you were trying to do, fulfilling your "any help will be appreciated!!!!"
request.

i recommend email Jon Skeet, ( http://www.pobox.com/~skeet ) who is on this
forums a lot, and seems to know a lot, more, if you require more assitance.

best of luck.
Dan.

"Hasani" <HJ****@hotmail.c0m> wrote in message
news:CU**********************@twister.nyc.rr.com.. .
well, while I read the stuff in the link (which is a lot)
can you at least tell me how I can return objects derived from System.Array
to COM or how to return an ArrayList to COM?
"Daniel Bass" <I'm really @ sick of spam> wrote in message
news:OT*************@TK2MSFTNGP09.phx.gbl...
check out the Interop tutorials on this page.

http://msdn.microsoft.com/library/de...pTutorials.asp


Nov 15 '05 #5
<"Daniel Bass" <I'm really @ sick of spam>> wrote:
i recommend email Jon Skeet, ( http://www.pobox.com/~skeet ) who is on this
forums a lot, and seems to know a lot, more, if you require more assitance.


Unfortunately I know precious little about COM - I know basically the
*exact* amount I've absolutely *had* to learn in order to do what I've
needed to do.

Asking a question in the microsoft.public.dotnet.framework.interop
newsgroup is *much* more likely to get a satisfactory response, however
:)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #6
and I thought you knew everything!?!?

I'm busy trying to write the COM.Interop way for instantiating an MMC
Snap-In, it's luvly. ;op

Dan.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<"Daniel Bass" <I'm really @ sick of spam>> wrote:
i recommend email Jon Skeet, ( http://www.pobox.com/~skeet ) who is on this forums a lot, and seems to know a lot, more, if you require more

assitance.

Unfortunately I know precious little about COM - I know basically the
*exact* amount I've absolutely *had* to learn in order to do what I've
needed to do.

Asking a question in the microsoft.public.dotnet.framework.interop
newsgroup is *much* more likely to get a satisfactory response, however
:)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #7

Yesterday, I did come across (How Do I...Pass an Array From .NET Code to VB6
Code)
http://samples.gotdotnet.com/quickst...tServer_2.aspx
Now, I just copied and pasted it as:

public interface ITest
{
Int32[] GetArray();
}

public class Test : ITest
{
public Test()
{
}

public Int32[] GetArray()
{
Int32[] int32Array = {0,1,2,3,4,5,6,7,8,9};
return int32Array;
}
}

and the vbs code looks like

Set tst = CreateObject("iCode.Test")
Dim teh
teh = tst.GetArray()
Dim mer
mer = IsArray(teh)
MsgBox mer, , "VBS test"

I get a message box with saying "TRUE" which means that GetArray succesfully
returned an array. At this point, I have not clue how to access it
I tried doing teh(1) and I get "Type mismatch" error when I add the lines

Dim valz
valz = teh(1)

to the end.

Man, all I wanna do is access my .net library code from asp. =(
"Daniel Bass" <I'm really @ sick of spam> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
That there is I suppose, but the question you posed doesn't warrant a short solution, from the stand point it would be more beneficial to understand
more about what you're trying to do.

With regards your arraylist question, I'm unaware of an ArrayList structure existing outside the .Net framework? This means what would be required is a conversion to a more generic (or unmanaged) state. Rather than passing out a defined .Net structure. So ArrayList myArray would be better as Int[1024]
aryintMyArray.

I don't really understand all the in's and out's of it all, but found the
submitted articule useful in providing the info required to accomplish what you were trying to do, fulfilling your "any help will be appreciated!!!!"
request.

i recommend email Jon Skeet, ( http://www.pobox.com/~skeet ) who is on this forums a lot, and seems to know a lot, more, if you require more assitance.
best of luck.
Dan.

"Hasani" <HJ****@hotmail.c0m> wrote in message
news:CU**********************@twister.nyc.rr.com.. .
well, while I read the stuff in the link (which is a lot)
can you at least tell me how I can return objects derived from System.Array to COM or how to return an ArrayList to COM?
"Daniel Bass" <I'm really @ sick of spam> wrote in message
news:OT*************@TK2MSFTNGP09.phx.gbl...
check out the Interop tutorials on this page.

http://msdn.microsoft.com/library/de...pTutorials.asp


Nov 15 '05 #8
OK, I think I got it to work by making my methods that return arrays return
object[] instead of whatever derived class they were originally returning.
Gonna be a suck though because I gotta modify like 30 classes =/
I got some insight in a reply from Alex @ msft.pub.scripting.vbscript
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<"Daniel Bass" <I'm really @ sick of spam>> wrote:
i recommend email Jon Skeet, ( http://www.pobox.com/~skeet ) who is on this forums a lot, and seems to know a lot, more, if you require more
assitance.
Unfortunately I know precious little about COM - I know basically the
*exact* amount I've absolutely *had* to learn in order to do what I've
needed to do.

Asking a question in the microsoft.public.dotnet.framework.interop
newsgroup is *much* more likely to get a satisfactory response, however
:)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: dogu | last post by:
Noob alert. Code is below. File is saved as a .php. What I'm trying to do: User uses 'select' box drop down list to pick a value. Value ($site) is derived from a db query. This works fine....
73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
6
by: Jax | last post by:
Custom control problem. I'm modding a textbox so that it will always have a "%" sign at the end of it. I have overrided the Text property to account for the "%" value within the textbox and have...
20
by: SMG | last post by:
Hi All, I have created an application which is working fine and is in about to launch, now suddenly my mgmt says there are chances that Scrip ID( a particular id and not prim key) may have special...
138
by: Ian Boyd | last post by:
i've been thrown into a pit with DB2 and have to start writing things such as tables, indexes, stored procedures, triggers, etc. The online reference is only so helpful. The two pdf manuals are...
12
by: wheels619 | last post by:
How can I get access for another user's special folder locations? A configuration file is stored in the users' appData folder and the program altering it will be ran under the admin.
83
by: Anonymous | last post by:
Came across some code summarized as follows: char const* MyClass::errToText(int err) const { switch (err) { case 0: return "No error"; case 1: return "Not enough"; case 2: return "Too...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
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...

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.