|
Fairly obvious from your exception, you don't have permissions on your computer to open the port. Are you a normal (i.e. non-admin) user by any chance?
Just Google it.
Failing that try phoning
|
|
|
|
|
that is what I thought the problem was.....BUT I did run other sample code which I found at http://msmvps.com/blogs/coad/archive/2005/03/23/39466.aspx (the SerialPortTerminal.zip) and it opens up the COM port fine. Its just when i put this code in my sln that it returns that exception.
Did I now include some dll or project property that has me throw this exception in my sln only?
|
|
|
|
|
OK, I solved the problem although I do not understand why. The problem was that I was working under a network drive. As soon as I made the project reside on my local hard drive it worked fine.
So now my new question is, how do I make it so that my project can reside on the networked drive and still execute correctly?
|
|
|
|
|
Hmm, all I can suggest is look through your code carefully to see where it differs (in operation) from the sample code.
Another possibility is are you running your code off a mapped drive? If so you'll have to setup the permissions to trust that mapped drive. Even if it's mapped to a drive on your computer.
Just Google it.
Failing that try phoning
|
|
|
|
|
Greetz!
Can anyone tell me how to save objects in a file?
e.g. combobox is filled with objects form a class (name, which is displayed and value which includes IPEndPoints)
I want to save all Items of the combobox in a file, and load it later again.
All information is stored in the combobox.Text and combobox.Tag.
Other examle given: name is the name of a specific mode, and three string values define the parameters of the modes. This should be saved in a file as well.
Thx in advance,
Ezazazel
|
|
|
|
|
Since you havn't made it very clear how your data is represented / stored on the form, might I suggest you look into Serialization in the System.Serialization namespace?
Alternatively you can create your own file format and read and write data using the stream classes (System.IO namespace)
Or if you want to save it as Xml then take a look at the XmlTextReader, XmlTextWriter and XmlDocument classes in the System.Xml namespace.
Just Google it.
Failing that try phoning
|
|
|
|
|
You can use binary serialization and also you can use xml serialization for it.
For eg,
using System.Runtime;
using System.Runtime.Serialization.Formatters;
//Serilization//
Object s=new Object(textBox1.Text,textBox2.Text,textBox3.Text);
System.Runtime.Serialization.IFormatter f;
f=new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.FileStream outf=new System.IO.FileStrea(@"d:\s.bin",System.IO.FileMode.Create,System.IO.FileAccess.Write);
f.Serialize(outf,s);
//Deserializeation//
System.Runtime.Serialization.IFormatter f;
f=new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.FileStream fin=new System.IO.FileStream(@"d:\s.bin",System.IO.FileMode.Open,System.IO.FileAccess.Read);
Object s=(Object)f.Deserialize(fin);
Enjoy!!!!
<marquee>nishu
|
|
|
|
|
Wasn't that meant to be in reply to ezazazel?
Just Google it.
Failing that try phoning
|
|
|
|
|
Anyway, got it!
Thx for your help!
|
|
|
|
|
Thx for your help - am going to try it tomorrow.
|
|
|
|
|
This is my first post on this forum, and I am also new to C#.
I am trying to adapt my GDImage Win32.dll to managed code,
so far I have already translated my first graphic demo ZoomPlus,
and I am translating another one named AeroGlass.
AeroGlass, allows the user to move transparent alphablended sprites, with either the mouse or keyboard.
The mouse works just fine, however I have troubles with the keyboard focus using arrow keys.
It looks like the last button of my .NET form keeps the focus on itself,
even if my Win32.dll control uses SetFocus to gain the keyboard focus.
Do you have any suggestion on how to solve this problem ?
and remember I am new to C#, thus still learning...
Patrice Terrier
www.zapsolution.com
|
|
|
|
|
Hello
What I understood from your question is that you want to use an extended way to move your form using the keyboard but you are facing a problem that one of the form's controls -say a button- is having the input focues?
There is an event called Form.KeyPreview which is present in .Net 2.0 framework. You can use it to catch keyboard events in your form before theyu are sent to the controls and move your form according to the key pressed, but first there is a property named Form.KeyPreview also that you must set to true.
I hope that was what you are looking for.
Regards
|
|
|
|
|
Nader--
Thank you for your answer, what I want to do is not to move my form
or any control inside of it.
What I want to do is to move sprites like in game, using the arrow keys.
Thus when I put the focus on the graphic control it must keep it,
even if I am using the direction keys.
If I hold down CTRL+arrow + (up, down, left, rigth)
then I can move the sprites, and also when holding down SHIFT+CTRL.
But holding down a direction key, with or without SHIFT, doesn't work.
This is related to the fact that the form also uses the arrow keys
to navigate between the .NET child controls of the form.
In Win32 it is often the result of using a call to IsDialogMessage
in the WinMain message pump.
Being new to C# I have no idea of what .NET realy does under the hood
in its message pump that would cause this havoc.
|
|
|
|
|
zapsolution wrote: Thus when I put the focus on the graphic control it must keep it
Actually to make your control able to recieve focus -supposing it's inherited from the Control class-, you must call SetStyle(ControlStyles.Selectable, true) first. Otherwise it won't even recieve focus no matter how many Focus() calls or any other calls you make.
zapsolution wrote: This is related to the fact that the form also uses the arrow keys
to navigate between the .NET child controls of the form.
If you want to make the direction keys move the spirit even if the buttons have the focus, you can implement the solution I provided in my previous post, yet note that if the user presses Enter or Spacebar the button which has the focus will be pressed.
zapsolution wrote: Being new to C# I have no idea of what .NET realy does under the hood
in its message pump that would cause this havoc.
I don't see much of a havoc here. The message pump in .Net forms is very much similar to Win32, in fact you can send Win32 messages to .Net forms normally!! Also you can implement IMessageFilter interface to filter messages of your form before being processed, but I don't think that would do you much help. What you really need is to set the focus to the graphics control. Try the SetStyle() method in your control's constructor as it's a protected method.
Regards
|
|
|
|
|
Perhaps my problem is that the graphic control itself, is not created by the .NET machinery, but inside of the Win32.dll (using the low level CreateWindowEx API).
Then the problem is how to use SetStyle(ControlStyles.Selectable, true)
with a control that is not created in a .NET class ?
|
|
|
|
|
I'm trying to create a custom DataGridColumStyle object that has a color dialog attached. When the user clicks the cell the color dialog is displayed and a new color can be selected and then displayed in the cell.
The problem is... I just don't have a clue where to start.
I've previously created a custom column that uses an enum to populate a combo box so I thought it wouldn't be a problem but I was wrong
Can anyone help?
|
|
|
|
|
Place code like
MyColorDialog dialog = new MyColorDialog();
dialog.ShowDialog() in DataGridColumnStyle.Edit method
|
|
|
|
|
i want to record sound , help me please !!!!!
|
|
|
|
|
|
I found this example in MSDN and download it , but it doesnt work ,it was because of wavein /waveout class .i couldnt get that how to work .
but you show me a complete solution of that .
Thanks
But
please dont judge when you dont know anything about me ,
"i searched Record Sound C#" and nothing suitable result!!!
|
|
|
|
|
Hi all,
Iam working on a windows application where we have to do backgorund operation(Communication check with hardware) and have to update the GUI Status icon(if Commn. passed- Green color, failed-Red color). Initially i used the windows timer to do the background commn check but this was sometime hanging the GUI. so i changed this into a system timer operation but this introduces the thread safe problems since i have to update the GUI thread's status icon on the system timer's thread. is there any way to do this. is there any spl class available on .net for doing background operation. without affecting GUI.
Thanks
Srini
|
|
|
|
|
Keep using the System.Timers.Timer and use Invoke or BeginInvoke to update your GUI. This article[^] probably helps you in doing so.
"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
|
|
|
|
|
i have tried to use invoke in timer thread. but some times i get a exception Object disposed or windows handle has not been created. but this background worker components sove the issue.
Thanks
|
|
|
|
|
how bout you try running your process on another thread? try using the BackgroundWorker.
|
|
|
|
|