I found a solution when i made a little exsample application concentrating on this whole using library business (for a prof who did not quite understand my problem):
It turns out to run properly when i refer to ChatMsg as localhost.ChatMsg (i think it's the namespace of the proxy) not using or refering any ChatLib in the client. This might not have worked for the original purpose because of the messy code, i have to tidy it up i guess
Hi! I've been working with C# for a while now but have hit a few snags...I would sure like info about the following things:
1. Hardware and C#
2. Accessing hardware serial numbers in C#
3. Computer System Hardware Classes and C#
4. Accessing Win32_BIOS - Win32_DiskDrive functions in C#
5. How to get a list of functions contained in a DLL file
Any help would be appreciated and thanks for the time spent on answering this beforehand...
For anything Win32 related you should go to MSDN[^] and check out Eric Gunnerson's latest article. He has a really good explanation of how to do Win32 stuff from C#.
As for the hardware related issues...I don't think you can do that in C#. I believe you would have to use, again, the Win32 API. However, you may not even be able to do that(You might have to go all the way down to Assembler).
And lastly, as for the DLL. You can use the System.Reflection.Assembly class to load a DLL and examine it's properties and methods. Even if it's a COM DLL, then .NET will create a wrapper for you and you'll be able to see the info that you want.
Properties are a replacement for all those get/set methods we have in C++ / Java. It also allows you to expose a different type than the field you setting. AFAIK any fields should be never be public.
Hope this helps
"There are no stupid question's, just stupid people."
Yeah, its best to use properties rather than public fields. A property acts as an encapsulation around and a buffer between a classes private fields and the function accessing them.
Where with a public field all you can do is get and set:
public int ABool = 0;
Test t = new Test();
t.ABool = 1;
A property allows you to do many things before the field itself is set. A property also allows you to restrict the access to a field, allowing only getting or setting, if that is what your class requires:
private int aBool = 0;
public int ABool
// restrict the value of aBool to positive and zero
if (value >= 0)
aBool = value;
If I understand the question correctly...this may give a good definition.
Property: This is exposed via public accessors (get/set) that allow a user to indirectly modify an internal variable. This process allows the developer to a) encapsulate the actual data b) include process against the data before it is set in the variable c) define that variable as read-only / write-only / read/write-capable.
Field: Directly exposes an internal variable as PUBLIC. This, to some extent, breaks encapsulation, does not keep control of the variable within the control of the object, and is not CLS Compliant. No process can be performed against the public property (such as security or business logic) and as such the value of the variable should be treated as suspect by the owning object.
Does this help?
--------------------------------------------- Once I thought I was wrong but I was happy to discover that was a mistake.
theRealCondor wrote: Field: Directly exposes an internal variable as PUBLIC. This, to some extent, breaks encapsulation, does not keep control of the variable within the control of the object, and is not CLS Compliant. No process can be performed against the public property (such as security or business logic) and as such the value of the variable should be treated as suspect by the owning object.
I don't understand your statment, you can set the field to be public AND readonly in which case control of the variable is kept within the object that contains it.
ASP.NET can never fail as working with it is like fitting bras to supermodels - it's one pleasure after the next - David Wulff
You are correct in stating that I can do: public readonly int myInteger
and that variable will be in my control as far as it being a computed field. But I still cannot maintain control over that property as to who can access this property, nor can I hide the implementation of the data.
I also was not looking at specific instance examples, but rather full utilization of either public accessors or exposed public fields. So from that all-or-nothing viewpoint, my statement still holds true. Just to make sure we are on the same page....this is the definition I go by:
Encapsulation means that a group of related properties, methods, and other members are treated as a single unit or object. Objects can control how properties are changed and methods are executed. For example, an object can validate values before allowing property changes. Encapsulation also makes it easier to change your implementation at a latter date by letting you hide implementation details of your objects, a practice called data hiding.
From this definition, even if I maintain some amount of encapsulation with the public readonly direction, I also do not hide the implementation of that data. As such, if that integer now has to be long, I just broke my consumer because they know my implementation is integer. Thus I have broken some form of encapsulation.
_____________________________________________ I have a tendancy to where my mind on my sleeve I have a habit of losing my shirt...
Does anyone know how to create a program that can be operated via named pipes (I think that is what it is called)?
Two programs that I know of that use them are Microsoft Document Explorer (the help files for VS .NET) and Microsoft Money. The help files can be accessed using the "ms-help" pipe and Money can be accessed using the "money" pipe.
The functionality I would like in my program is much like Money, where if you enter a "money" address into Explorer or IE the program is launched and navigated to the right location.
I remember reading somewhere about how to do this but I haven't be able to find any information recently (I forgot what I searched for). Does anyone have an idea of how to do this? Or any references to some articles or help files somewhere that describe the process of APIs used.
Last Visit: 31-Dec-99 19:00 Last Update: 4-Dec-23 18:58