473,796 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ShowDialo g(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 1413
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*********@Nn OwSlPiAnMk.comw rote:
>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(allc fg);
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*********@Nn OwSlPiAnMk.comw rote:
>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
6408
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 to happen we had to change the context in which asp.net runs from machine to SYSTEM by modifying the machine.config file. Under Windows 2003 no matter how asp.net is set to run as either machine or system. I get the following error: ...
22
3276
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 code just works fine: WebRequest request = WebRequest.Create(URL);
0
2727
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 to export reports that have linked subreports. I receive (a "Missing parameter field current value") on the following statement: Me.crReportDocument.Export() The main report requires 4 parameters. The linked reports do not require any...
0
12069
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 '/CinemaBookingSystem' Application. -------------------------------------------------------------------------------- ERROR General error Unable to open registry key 'Temporary (volatile) Jet DSN for process
4
6451
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 to get connected. below is my script. <?php $connection_string = 'DRIVER={PostgreSQL};SERVER=10.2.1.4:5432;DATABASE=Admin';
3
24243
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 this? System.Web.Services.Protocols.SoapException: Server was unable to process request. ---System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file g:\inetpub\wwwroot \BankingService\App_Data\BankingDb.mdf failed....
3
2403
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 the name of the city and I have a DIV tag which I populate with the results. Now my problem is that, after I get the results back I am not able to select a value from the DIV tag. Here is the complete jsp code. <html> <head>
1
1622
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 Request.cs to a webservice method SaveRequest(Request req). 4) Scenario is like same Request.cs is referenced by both server and
9
2897
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 thought that I would be able to reference the textbox simply by placing the name of the form it is located on (class name) in front as follows... param1 = frmSteelPlates.txtJobNo.Text I am getting the following error when I debug the line to...
0
9684
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
9530
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10236
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10017
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
9055
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
7552
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
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
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.