473,408 Members | 1,746 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,408 software developers and data experts.

Variant problem with COM,C# ---help me

Hi ,

Pls help me to solve this problem .

/* --this is one of the function in COM component */

System.int32 ProjectLIsts(LPCTSTR prj , VARIANT* prj_list)

{
prj_Lists= { ARRY OF STRUCTES . ,.ONE STRUCTE FOR EACH PROJECT }

returns TOTAL NUM of PROJECTS
}

???.
If I add this COM component to my .net project , then it converted
as

System.Int32 ListProjects (System.string , System.Object prj_list )

Then I wrote the code as

API obj=new API();
int no_of_projects;
object p;
no_of_projects =Obj. ProjectLIsts(" " , out p);

here it returns no_of_projects correctly but if I use out variable p I
got
null reference exception

How can I read the array of struct
here I got no_of_projects is correct .But how can read p data .

If I print Console.WriteLine(p.GetType())

I got Null reference exception .

Could any one help me

Regards,
Thanks in advance

Jun 29 '06 #1
1 1125
srinivas,

You can't just pass the array as a pointer to a Variant. You have to
pass a SAFEARRAY structure in order for COM interop to correctly pass the
array between .NET and COM.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"srinivas" <ch*************@gmail.com> wrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi ,

Pls help me to solve this problem .

/* --this is one of the function in COM component */

System.int32 ProjectLIsts(LPCTSTR prj , VARIANT* prj_list)

{
prj_Lists= { ARRY OF STRUCTES . ,.ONE STRUCTE FOR EACH PROJECT }

returns TOTAL NUM of PROJECTS
}

???.
If I add this COM component to my .net project , then it converted
as

System.Int32 ListProjects (System.string , System.Object prj_list )

Then I wrote the code as

API obj=new API();
int no_of_projects;
object p;
no_of_projects =Obj. ProjectLIsts(" " , out p);

here it returns no_of_projects correctly but if I use out variable p I
got
null reference exception

How can I read the array of struct
here I got no_of_projects is correct .But how can read p data .

If I print Console.WriteLine(p.GetType())

I got Null reference exception .

Could any one help me

Regards,
Thanks in advance

Jun 29 '06 #2

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

Similar topics

4
by: Steve House | last post by:
I'm running VS.Net 2003 on an XP system with the most recent MSDN library integrated into it. When you do a search in the help, only "a"'s appear in the search results title column as a column 1...
0
by: Prasanth U | last post by:
Hi All, We are facing a problem while integrating a HTML help file (chm version 1.x) to our windows .net application (C#). The help topic for the controls in the application are shown using the...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
1
by: JJ | last post by:
Ok I have now got to grips with HTML help workshop and created my help files, TOC etc. Now how do I integrate this with my application? I have added an errorprovider to my form and pointed it to...
2
by: Trax | last post by:
and recommendation for C# and .NET hosting with Help panel? and last software MS SQL 2005, :NE Framework 2
6
by: WhiteWizard | last post by:
Hello all, I have been tasked with coming up with a system for providing help for our users, and we have some somewhat unique requirements. NO INTERNET. This is a windows application that will...
5
by: Peertje | last post by:
Hi group, I would like to show the latest aurora data on my site. I know this is possible with help of a php-script, but I'm a nitwit with php-scripting. That's why I'm asking for help here. ...
6
by: Orin | last post by:
Hi! If anybody knows how to output formatted HTML code in command line with help of PHP (or other way), please help me. With best regards, Orin
5
by: vedasri | last post by:
how the images can be placed side by side with help of css background image in <div>
1
by: Deepak Wadhwa | last post by:
how to make report with help of D2k in oracle?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.