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

Unable to pass an object

I have a form that invokes two other dialog forms for controlling the
configuration of the program. The dialogs are invoked modally. Rather
than pile up a large number of variables in the primary form I created
a class to hold the configuration data, validate it, save it. etc. An
object of this class is in the main form. The data is all private but
I have public accessors for all of it. My need is to make it
availlable to the two sub-forms when I call them but no matter my
method of approach I get stymied in the compile with a variety of
errors, depending on the methodology I'm trying.

I've make the object public, private and tried to pass it to a newly
constructed form via a public method in the sub-form before showing
the dialog (I'm successful with individual items, but not the class
object.) When I make it private, it's not available in the context of
the sub-form. This I can understand. When I make it public and try
to pass it via a function I get an error along the lines of

Inconsistent accessibility: parameter type 'GWIAmon.AllCfg' is less
accessible than method 'GWIAmon.Config.SetCfg(GWIAmon.AllCfg)

I think what I'm seeing from searches is that the object has to be of
a public class, though I'm not sure what that means.

Any help would be appreciated. Right now the code is looking awfully
ugly and since I need to do this in at least two places, I'd like to
make sure that I'm not dropping data by passing member data one at a
time.

On this same note, if I do

form2.ShowDialog(this);

Where is "this" represented in form2 to such that I might have acces
to it? Or is this solely for the benefit of the form to know what
owns it?

--
Thanks,
Lilith
Aug 16 '07 #1
4 1398
Lilith wrote:
[...]
Inconsistent accessibility: parameter type 'GWIAmon.AllCfg' is less
accessible than method 'GWIAmon.Config.SetCfg(GWIAmon.AllCfg)

I think what I'm seeing from searches is that the object has to be of
a public class, though I'm not sure what that means.
It sounds as though your class is called "AllCfg", that you have a main
form class called "Config", which has a public method "SetCfg". Is that
correct?

If so, then the error is complaining that the method is public, but the
class "AllCfg" is not. If you don't put the "public" key word as part
of your class declaration, then the class isn't public and can't be used
as the type in other public members, like a method return type or
parameters.

So, in other words, the searches you've apparently already done have
already told you the problem. You just need to declare the class as
public. If you understand the difference between other things being
public, protected, private, or internal, then it's not clear to me why
you wouldn't also understand what it means for a class to be public.
It's the same thing.

If the above doesn't answer your question, you need to post a
concise-but-complete sample of code that demonstrates the problem you're
having. That way someone can explain how to change the code so that it
works.

Pete
Aug 16 '07 #2
On Thu, 16 Aug 2007 15:06:53 -0700, Peter Duniho
<Np*********@NnOwSlPiAnMk.comwrote:
>Lilith wrote:
>[...]
Inconsistent accessibility: parameter type 'GWIAmon.AllCfg' is less
accessible than method 'GWIAmon.Config.SetCfg(GWIAmon.AllCfg)

I think what I'm seeing from searches is that the object has to be of
a public class, though I'm not sure what that means.
>It sounds as though your class is called "AllCfg", that you have a main
form class called "Config", which has a public method "SetCfg". Is that
correct?
Actually it's the sub-form that's of class Config and it's that class
that has the SetCfg method. From the main class I've done something
like the follow (code is back at the office right now.)

public AllCfg allcfg = new AllCfg();
..
..
..
using (Config cfg = new Config()) {
cfg.SetCfg(allcfg);
cfg.Show.Dialog();
// other stuff to do after return from the Config form
}
>If so, then the error is complaining that the method is public, but the
class "AllCfg" is not. If you don't put the "public" key word as part
of your class declaration, then the class isn't public and can't be used
as the type in other public members, like a method return type or
parameters.
>So, in other words, the searches you've apparently already done have
already told you the problem. You just need to declare the class as
public. If you understand the difference between other things being
public, protected, private, or internal, then it's not clear to me why
you wouldn't also understand what it means for a class to be public.
It's the same thing.
I grok an object being public. In my reading I haven't come across
the use of a public class, or at least, not a discussion of it such
that it sunk in. How is it different from a declaration of a public
object of the class?
>If the above doesn't answer your question, you need to post a
concise-but-complete sample of code that demonstrates the problem you're
having. That way someone can explain how to change the code so that it
works.
>Pete
--
Thanks,
Lilith
Aug 16 '07 #3
Lilith wrote:
I grok an object being public. In my reading I haven't come across
the use of a public class, or at least, not a discussion of it such
that it sunk in. How is it different from a declaration of a public
object of the class?
A class has an access level, just as a class member such as a field,
property, or method does. And just as you can explicitly specify that
access level for a class member, you do so for a class itself.

The important thing here is that it sounds as though your public method
is using a private class, which isn't allowed. All of the types that
are part of the method signature need to be public if the method itself
is public. Otherwise, there could be a situation in which the caller
has access to the method, but not the types required by the method.

I've left the following text from my previous post, which you quoted, as
a hint:
>If the above doesn't answer your question, you need to post a
concise-but-complete sample of code that demonstrates the problem you're
having. That way someone can explain how to change the code so that it
works.
Pete
Aug 16 '07 #4
On Thu, 16 Aug 2007 16:33:45 -0700, Peter Duniho
<Np*********@NnOwSlPiAnMk.comwrote:
>Lilith wrote:
>I grok an object being public. In my reading I haven't come across
the use of a public class, or at least, not a discussion of it such
that it sunk in. How is it different from a declaration of a public
object of the class?

A class has an access level, just as a class member such as a field,
property, or method does. And just as you can explicitly specify that
access level for a class member, you do so for a class itself.

The important thing here is that it sounds as though your public method
is using a private class, which isn't allowed. All of the types that
are part of the method signature need to be public if the method itself
is public. Otherwise, there could be a situation in which the caller
has access to the method, but not the types required by the method.
I think I've managed to grasp what you're saying.
>I've left the following text from my previous post, which you quoted, as
a hint:
>>If the above doesn't answer your question, you need to post a
concise-but-complete sample of code that demonstrates the problem you're
having. That way someone can explain how to change the code so that it
works.
I did some testing against some code I had available by making some
temporary modifications. It works fine.

Many thanks for your help.
Lil
Aug 17 '07 #5

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

Similar topics

2
by: Carlos G Benevides | last post by:
I have a ASP.Net web application that has two assemblies that run under com+. Under Windows 2000 the two assemblies are added to com+ automatically when instantiated from the web site. For this...
22
by: Kristof Thys | last post by:
Hello, I'm developing a C# - windows forms application. To get some information for my application, I'm connecting to an URL, wich gives me XML generated using php. With 90% of the users, this...
0
by: Henry | last post by:
I have written an ASP/VB.Net application via VS 2003 (Crystal V9) that uses MS Access 2000 as its database. I can export reports that have no linked sub reports for printing. However, I'm unable...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
4
by: newladder | last post by:
Hi all, Iam struck with one of the problem with postgres. Please help me out.... Iam trying to connect to connect to postgres database on remote machine with the IP address 10.2.1.4. Iam unable...
3
by: weird0 | last post by:
This is the exception that I get when i create a webserivce obj and call. The error comes on the webmethod call, when it opens a connection to the db. How do I fix it? What is the solution to...
3
by: ashishc | last post by:
Hi All, I have written a AutoSuggest in jsp and am using javascript to call the strut page which calls the database and returns me the xml back. On the html page i have a text box where i enter...
1
by: Rahul | last post by:
I am getting following error: 1) For a xml file "Request.xml" we created a schema "Request.xsd". 2) With the help of xsd.exe we got the C# file Request.cs. 3) We tried to send the object of...
9
by: Brad Pears | last post by:
I have the following code that references a "textbox" on a form. I want to pass the value of this textbox to a stored procedure as a parameter. This code is located on a different form obviously. I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.