|
Use the network MAC address :-
ManagementClass oMClass = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection colMObj = oMClass.GetInstances();
string macAddress = "";
foreach (ManagementObject objMO in colMObj)
{
if (objMO["MacAddress"] != null)
{
macAddress = objMO["MacAddress"].ToString();
break;
}
}
Is there a better, quicker way to get this anybody?
Regards
Malc
*********************************************
|
|
|
|
|
Mac addresses are changable. CPU(?)/mobo serials would be a better bet. You'll need to use WMI to get that sort of information.
|
|
|
|
|
Is there some reason the XML serializer doesn't support serializing a property whose type is an interface?
Is there some workaround to that, given that I WANT to serialize the property? A work around other than making an abstract class and using XmlInclude?
I don't know the concrete types to serialize, since the object I want to serialize can be defined in a different assembly, and I'd end up with a circular reference. Plus, I don't want to entangle the general purpose class I already have with application-specific implementations of objects that need to be serialized, hence the interface to begin with!
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Marc Clifton wrote: Is there some reason the XML serializer doesn't support serializing a property whose type is an interface?
what is there to serialize? Generaly you serialize "data", an interface contains no data.
If you want the data resulting from some method of the interface to be serialized then you need to represent that as a property where the type would be like "string" or whatever. Then the implementation of the property would call the method of the interface to produce the data.
led mike
|
|
|
|
|
led mike wrote: Generaly you serialize "data", an interface contains no data.
Xml serialization supports serializing objects, not just value types, building an object graph. In this case, the interface is implemented by some classes that I want serialized. Why the serializer can't simply output the type information is beyond me.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Marc Clifton wrote: Xml serialization supports serializing objects
Well I hate to point out the obvious but an interface is not a concrete object. Another approach could be custom serialization. Not very difficult.
led mike
|
|
|
|
|
Hi,
first of all the serialization mechanisms of .NET don't serialize properties - they serialize fields. This is important because not everything which determines the state of an object is accessible via its public interface. Are you getting some kind of exception? If the property encapsulates a field it should work as long as the concrete class hanging in this field is marked with [Serializable].
Robert
|
|
|
|
|
Hi
i devlope a application in which i used a lot of png image files.i place the image folder ,where the exe is,.
this is also working in release mode .but whenever i place .exe file to desktop it demand for image folder.
i have to put image folder to destop.
How can i escape of putting the image folder to desktop.
Can i place all image file to solution explorer then what the path would if this time path is
btn_select_folder.BackgroundImage=System.Drawing.Image.FromFile(Application.StartupPath+@"\dbxpngs\002.png");
plase tell some solution
parshant
|
|
|
|
|
Why do you put the program on the desktop? Put a shortcut to the program on the desktop.
---
b { font-weight: normal; }
|
|
|
|
|
I don't know, but it seems the crystal reports doesn't like me or my computer or something, because I can't get the following simple scenario to work:
- I used strongly typed datasets in the application to build my model with
- I Added a couple of forms and used databinding to connect the datasets
This all works fine, so I created a crystal report to print some of the data.
It's a report with a parent child-relation in it, because I'm showing a delivery note with delivery items on it. I used the wizard, so I can assume that works out.
But when I run the app and try to print something using the report, I get an empty report from my printer. After two hours of searching and finding it out myself, I'm out of options.
The code to load and print the report is as follows:
Pakbon report = new Pakbon();<br />
<br />
report.SetDataSource(ds);<br />
report.PrintToPrinter(1, true, 0, 0);
WM.
What about weapons of mass-construction?
|
|
|
|
|
A short update on the problem.
I thought it had something to do with me using multiple related tables, but I was wrong. After trying one more time, this time with a single table for the report head and a single table for the report details, that didn't work out.
WM.
What about weapons of mass-construction?
|
|
|
|
|
Its weird, but I solved it. Crystal report doesn't seem to eat more than one table per report. So I created a view which merges the data from the different tables and used that in the report.
Now everything is fine and my shipping items are showing up in the subreport, but I still think it's weird that it isn't possible to use more than one table in the report.
WM.
What about weapons of mass-construction?
|
|
|
|
|
string str = (string)value;
int i = str.IndexOf(".");
str.Remove(i, 1);
|
|
|
|
|
Because its not assigned to anything
I'm still thinking like a 'C' prgrammer.
Doh!
|
|
|
|
|
Remember strings in C# are immutable, so you need something like str = str.Remove(i, 1) if you want to modify a string.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
It works just fine, it even creates the string that you want. It's only that you don't keep the reference to the string, so it floats around in heap limbo until it gets garbage collected.
So close...
---
b { font-weight: normal; }
|
|
|
|
|
How would i go about assigning the F12 key to focus on a textbox within a form? Meaning when a form is active, if the f12 key is pressed (doesn't matter which component is active) the focus will be set to a certain textbox.
I know how to set the event when a certain component is active, but if i want to set a global keyup event, how would i do so?
Here is the code for a textbox keyup:
this.textBox_units.KeyUp += new System.Windows.Forms.KeyEventHandler this.textBox_units_EnterKeyPressed);
private void textBox_units_EnterKeyPressed(object sender, System.Windows.Forms.KeyEventArgs e )
{
if(( e.KeyCode == Keys.Enter ) || ( e.KeyCode == Keys.Return ))
{
this.textBox_upc.Focus();
}
}
|
|
|
|
|
Register to the KeyUp event of your form and set its KeyPreview property true .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
works like a charm
thanks
|
|
|
|
|
Hi,
I want to create a setup for a C# application. After the installation the setup should be deleted. Do you have any idea about this?
Pls tell me how to do this )
Thanks!
jayasshc
|
|
|
|
|
csecharithjayasshc wrote: I want to create a setup for a C# application
There are many ways to accomplish this. E.g. you could use a Visual Studio setup project or a open-source tool like NSIS[^].
csecharithjayasshc wrote: After the installation the setup should be deleted
Why would you do that? Maybe the user want to store the setup so he doesn't need to download it aganin if he wants to reinstall or use the app on another computer.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi there,
I'm guessing if anybody knows how to manipulate Access relationships using the Microsoft.Office.Interop.Access package. What I'm trying to do is to deactivate the referencial integrity option (I hope it is so named in english) so I can change values that act as primary keys (I know, it's a bad idea, but we need to). Later, when primary keys are changed, I want to restore referencial integrity.
I've tried to manipulate the MSysRelationships table, but I have no read permission. I have also throughly reviewed the object model, but to no results.
Does anybody know how to achieve this?
Thanks in advance,
Juan Pedro Pérez
|
|
|
|
|
Hi!
I'm trying to get a table schema from a Oracle database. I've tried it doing a "select * " from the table and after using "GetSchemaTable" from the OleDbDataReader.
My problem is that it doesn't show me the primary key's. Help me!!
|
|
|
|
|
Hello all!
Please help me understand the following "little" problem:
I'm trying to find the printers which another mashine in the network sees. For that, I'm using the following piece of code:
ManagementScope ms = new ManagementScope("\\\\Someone\\root\\cimv2);
ObjectQuery oq = new ObjectQuery("Select * from win32_Printer");
ManagementObjectSearcher os = new ManagementObjectSearcher(ms, oq);
ManagementObjectCollection queryCollection = os.Get();
I mention that my permissions on the other pc are granted both for the CIMV2 and WMI
(as set through My Computer>Manage>WMI Control>Properties>Security)
If the installed printers are shared on the other computer, I see them, otherwise the queryCollection is empty. WHY?
PS: When querying anything else, it works with no problems (for example,win32_Product).
Thanks for any comment!
SkyWalker
|
|
|
|
|
Hi,
I have a AxWebBrowser control in a dialog and I would like to populate same fields of the HTML page hosted by it when it comes up.
For example, if I want to browse to the Yahoo email page, I'll put
axWebBrowser1.Navigate("https://login.yahoo.com/config/mail?.intl=us");
but I would like to set the user name in the Yahoo ID field.
Any ideas on how to do that?
thanx
|
|
|
|