|
main points to keep in mind in making chess in c#.
rao nasir ali khan
|
|
|
|
|
|
Excellent answer !!
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello,
I am using properties from Properties.Settings.Default.* in my background worker thread. I was wondering if they are thread safe or not ? moreover if two threads try to read the same settings value at the same time, (NOT WRITE, just READ) is there any chance that my application will crash throwing exception ?
Thanks
|
|
|
|
|
Any shared resource that is read-only (that is, no threads are writing to the resource) is inherently thread safe. So unless you've got another thread writing to the settings, yes, 2 background threads reading the settings is safe.
|
|
|
|
|
Hi.
Thanks for your reply.
Regards
|
|
|
|
|
My application accepts single string databaseaddress.
I think the best form for this is
servername:port/databasename
parts other than servername may be missing. So legal forms are also
servername
servername:port
servername/databasename
samples:
143.44.454.45:33/mydb
myhost@mycomp.com
myhost@mycomp.com/mydb
How to extract servername, port and databasename to separate variables ?
servername, port and databasename does not contain : and / characters.
There is no need for syntax check.
|
|
|
|
|
I think System.Uri.TryCreate method will work for you.
|
|
|
|
|
i am working on a Point of sales application in C#. I want to redirect the values to the pos device connected to LPT1. Can anyone tell me how i can do this.
Thanks for your help
Regards
Hari
rkharikrishnan.bizhat.com
|
|
|
|
|
Isn't LPT1: just printing it?
|
|
|
|
|
You can connect arbitary devices to the parallel port, not just old printers.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Of course you can. I remember the old ZIP drives that hooked up to the parallel port and took forever to read and write.
My message seemed to be truncated (or I just forgot to hit update ). My point is that when you connect a device to the port, it will need some kind of driver. Then you can interface with that driver.
|
|
|
|
|
VS05 provides a class for the parallel port. IIRC it's in the system.io.ports namespace that should allow you to write to it. If you're using VS02 or 03, you'll have to google up a 3rd party implementation. Try the articles here as a starting point.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Thanks for the reply. i tried using system.io.ports namespace. But its showing only serial ports data. What should i do to send to both com1 and LPT1 ports? How can i check whether it is open?
Regards
Hari
|
|
|
|
|
I developed an Add-in for Outlook 2003 with Visual Studio 2005 Team Suite.
My solution was created via:
Other Project Types -> Extensibility -> Shared Add-in
And I selected support for Microsoft Outlook.
Question 1:
I uncheched all the "Exclude" option of the assemblies in the Setup Project and builded it successfully.
The Add-in installed and ran well in another computer which had also VS 2005 Team Suite on it. However, on a third computer, which only had .NET Framework 2.0 but not VS 2005, the Add-in installed normally but did not load when Outlook started. What's the problem?
Question 2:
My CommandBarButton runs only a few times.
I added a CommandBarPopup to the Main Menu and then added a MsoControlType.msoControlButton to the popup. In the ClickEventHandler of the button, a Windows Form object is created and shown.
The problem is, each time I start Outlook, the button is available for only a few times, usually 2-3 times, sometimes only once. Afterwards it becomes unavailable at all. It gives no response when I click it.
Some of the codes are as follows:
//Acquire the "Menu Bar" and create a new control on it
menuBar = ((Outlook.Application)applicationObject).ActiveExplorer().CommandBars["Menu Bar"];
commandBarControl_CM = menuBar.Controls.Add(MsoControlType.msoControlPopup, 1, "", 6, true);
commandBarControl_CM.Visible = true;
commandBarControl_CM.Caption = "Sychronization";
//Add buttons to the newly created control
CommandBarPopup commandBarPopup_CM = (CommandBarPopup)commandBarControl_CM;
CommandBarControl commandBarControl_SI = commandBarPopup_CM.CommandBar.Controls.Add(
MsoControlType.msoControlButton, 1, "", 1, true);
commandBarControl_SI.Visible = true;
commandBarControl_SI.Caption = "Calendar Sychronization";
//Add button event handlers
CommandBarButton button_showinfo = (CommandBarButton)commandBarControl_SI;
button_showinfo.Click += new _CommandBarButtonEvents_ClickEventHandler(button_showinfo_Click);
private void button_showinfo_Click(CommandBarButton Ctrl, ref Boolean CancelDefault)
{
System.Windows.Forms.Form form_CalMng = new Form_CalMng();
form_CalMng.Show();
}
|
|
|
|
|
Question 2 has been solved. The button object has to be declared at class level.
But help me with Question 1, please!
|
|
|
|
|
I begin to believe that it has something to do with the developing environment. I tried the Add-in on two computers WITHOUT VS2005 and got the same result, which is that the Add-in did not load. However, I tried it on another two computers WITH VS2005 on them and the Add-in loaded successfully.
Any hint?
|
|
|
|
|
Hi All,
A project I am working on requires me to interface DCOM components on a Windows NT machine with a server running 2003 with .NET 2 on it.
The problem is I can't seem to find any good advice on how this can be done. Specifically the client can not change and thus I require something like a wrapper so that the client can create a connection to the server via DCOM, but the server will be dealing with it via .NET remoting.
Can anyone point me in the right direction of how this can be done?
Thanks
Andy
|
|
|
|
|
Hello again,
I have looked in the docs and searched the net, but either it can't be done, or I'm not looking in the right place.
I would like have a property that is deserialised, but is not serialised. Why? Well, imagine an XML doc that allows
<person fullname="John Smith"/>
and
<person firstname="Jane" lastname="Doe"/>
However, when serialized we always want fullname, as in:
<person fullname="John Smith"/>
<person fullname="Jane Doe"/>
How do I deserialise firstname and lastname in the input file, but keep them from being serialised in the output?
Thanks again,
Clive Pottinger,
Hamilton ON
|
|
|
|
|
|
Hi
I'm affraid that's impossible but you can have a computed property ( which concats the first name and last name and returns the full name) and you can ignore it using XmlIgnore attribute.
I mean:
<br />
[XmlIgnore()]<br />
public string FullName<br />
{<br />
get<br />
{<br />
return this.FirstName + " " this.LastName;<br />
}<br />
}<br />
<br />
Regards
|
|
|
|
|
beatles1692 wrote: Hi
I'm affraid that's impossible but you can have a computed property ( which concats the first name and last name and returns the full name) and you can ignore it using XmlIgnore attribute.
Thanks. That's too bad. I'll have to see what I can do about changing the specs.
Clive Pottinger,
Hamilton ON
|
|
|
|
|
Bonus - I solved two in one day.
You can have an attribute that is deserialised but not serialised.
Give the item a property with a DefaultValue attribute and then have the get method always return the default value:
<br />
[XmlAttribute("firstname")]<br />
[System.ComponentModel.DefaultValue("----")]<br />
public string Firstname<br />
{<br />
get<br />
{<br />
return ( "----" );<br />
}<br />
set<br />
{ <br />
this.Firstname = value;<br />
}<br />
}<br />
Voila! Now, when deserialising, firstname is parsed, but when serialising, the firstname attribute is never written. Works like a charm.
Clive Pottinger,
Hamilton ON
|
|
|
|
|
Hello everyone,
My questions is in regards to finding information for an ancestor item while deserialising an XML document. The following is similar to the problem I am facing:
<teacher name="Johnson">
<class name="Hydrodynamics 101">
<student name="Billy"/>
</course>
</teacher>
I have classes for objects Teacher, Class and Student.
When a Teacher is deserialised, all the Class objects are created and passed to Teacher.AddClasses where each class is added to a private ArrayList Teacher.ClassList. Additionally, the Class.TeacherName is set. So far so good.
But during the creation of the Class objects, C# needs to create the Student objects. So the Student objects are deserialised BEFORE the Class objects are passed to Teacher.AddClasses. We are getting there...
When a Student object is created, I wish to add the student to the ArrayList Teacher.StudentList. That is a problem. Because the Class has not yet been added to the Teacher and had the Class.TeacherName value set, the Student object is unable to find out which Teacher it should be added to. We can't even search the Teacher objects looking for one that has that Class in Teacher.ClassList, because the Class has not been added there yet either.
Does anyone know a way around this? Is there a way, during deserialisation, to find out the Student["billy"] belongs to Teacher["Johnson"]?
Note: This is not exactly the situation I am facing: it is just a simplified example. So, though it may seem easier to rearrange the XML into a better order, that is not going to be an option for me. I need to deserialise object C inside B inside A and add C to a value in A while doing so.
Many thanks in advance.
Clive Pottinger,
Hamilton ON
|
|
|
|
|
Isn't it possible to set the teacher name in AddClasses . You could simply iterate through the student list in the class and set the teacher name.
|
|
|
|