|
HI,
What information is seen when the details button on the Unhandled exception dialog is clicked. The exception type and a stack trace should be available even if the application was built in release mode with debug information set to none.
Ask your clients to
1) highlight the detailed information by dragging over it with the mouse
2) Press Ctrl-C to copy the highlighted text to the clipboard
3) Paste into Notepad
4) Send you the file.
Alan.
|
|
|
|
|
I don't know if I'm on the right message board but I could at least give it a shot...
I'm testing with NUnit. The code itself has been written in Microsoft Visual Web Developer 2008 Express Edition. I need to debug a test. Therefore I have set a breakpoint to start step-by-step debugging at a certain point.
However, NUnit skips the breakpints and runs the test all the way throught at once. How can I make NUnit pause at the breakpoints so I can do some step-by-step debugging?
Thanks in advance!
|
|
|
|
|
Dear All,
I have an application which will be deployed by clickOnce,
I have a Service Project in the same project, I want that when Installing the Application via the URL the service should be installed in Client Computer, as the application is avilable both Online and Offline.
any ideas, Like is it Possible to deploy the Application and Install the service via Click Once Deployment?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Pls i want to access the private methods and events of a MDIChild Form from its parent Form and execute them, I do not know the how.
Thanks.
|
|
|
|
|
Firstly: you shouldn't do it. If method is to be called from outside of the class, it should be public, not private. And that's the path you should follow.
The backdoor to access private methods and fields is reflection (but it's bad). But I think you can solve your issue by changing methods' access to public.
|
|
|
|
|
You can also try Protected Friend in their declarations
|
|
|
|
|
Hi,
I am new to multithreading, and I am considering implementing multithreading in my code.
I am using MDI application with two child forms. On first child form I have all the controls and user interface (ChildForm1).
Second child form is used for data analisys and drawing graphs (ChildForm2).
ChildForm1 implements:
1) serial port communication (communication with microprocessor on PCB board)
2) data acquisition from intrument connected to computer (LAN) (up to 200ms for each data acquisition)
3) data processing and controls
Currently I am using timer control to comminicate over serial port (10 times per second - checking the conditions), triggering
data acquisition (when conditions are met) and finaly processing data and drawing graphs on another child form (real time).
As I use single thread, I am experiencing some delays (application not running smoothly as it waits for comm process and data processing).
What would be the right approach in setting multithread application ?
|
|
|
|
|
Hi,
There basically are two schemes you have to choose from.
1.
if the timer is a Windows.Forms.Timer and your Tick handler is short (less than 10 msec), then everything should be OK. That requires there are no blocking I/O methods called. So when your peripheral needs 200 msec to perform a data acquisition, it would only work smoothly if that gets handled asynchronously, i.e. in one timer tick you issue a "start acquisition" command without waiting for the results; and in a different handler (or a later tick of the timer) you issue a "now deliver the available data" command.
2.
If the above is not possible, the alternative is to have a second thread that takes care of communicating with your peripheral and preparing the new data; it should then use the Control.InvokeRequired/Invoke pattern to update the GUI. See this little article[^].
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
modified on Monday, June 7, 2010 8:39 AM
|
|
|
|
|
Hi!
I am making a setup installer(windows installer) which will install my application .I require a serial number window to integrate. I am using the "Customer information" window of setup project. There is an option of serial number entry. But the problem is i cant change the algo of validate serial key. the in-built algo is too week. Please help me, tell me how i can integrate serial number in "setup.msi"
Thanks!
|
|
|
|
|
Here is really nice tutorial how to customize Windows installer msi packages.It demonstrates how to solve your problem and lots more.
Life is a stage and we are all actors!
|
|
|
|
|
Hi,
How can I convert PDF to Tiff through C#?
Best wishes
|
|
|
|
|
See here[^].
My signature "sucks" today
|
|
|
|
|
Hi all,
Apart from saving setting of app in DB , what are other option which one can use.
I know few like saving in registry, file.
But applications like ccleaner, and some small utilities, dont think they save it in registry, or file. As in their program files directory there present no file.
So ,How they able to save settings ?
a) How they achieve this?
b) Is there a way by which i can embed my DB file inside .exe/.dll file.
Regards
|
|
|
|
|
I don't know for sure how does ccleaner do it, but I suppose it saves it in file located in your user profile. On Windows XP it would be somewhere in "C:\Documents and Settings\%user name%\ApplicationData" (I don't remember exact path and I don't have XP to check ). In Vista and 7 it's somewhere in "C:\Users\%user name%\AppData". Take a look at this[^]. It provides you with paths, where you can store settings for every user. You should use "Environment.SpecialFolder.ApplicationData" probably and create there subdirectory for your application. This way you will be able to store settings for every user. When those settings are stored in application directory, they are common for all users and when one user changes something, all users are affected. And why write code to support multiple users, when system does it for you
|
|
|
|
|
|
As for your b) question:
Yes, you can embed your database in the executable. I got this using Google ("c# embed file in executable"), and it looks pretty good:
http://www.cs.nyu.edu/~vs667/articles/embed_executable_tutorial/[^]
However, I don't know of any database system that will let you USE the database WHILE it is embedded, so once your program is installed and you need to use the database, you will need to extract it...
|
|
|
|
|
I create my own configuration files; XML, generally in either the user's or all users' application data directory.
Even if most of the configuration is in a database I still need a configuration file to tell the application how to connect to the database.
<Junkyard>
<Databases>
<Junk Provider="SqlServer" Parameters=".\SQLEXPRESS,Junk" />
</Databases>
</Junkyard>
|
|
|
|
|
I am read plots from serial port and draw it ....
I have problem with flickers ...and use DoubleBuffer property to solve the problem ... but flickers increase rather than the first .... what i should to solve problem ....
what is the best design for Application to smooth drawing ?
|
|
|
|
|
flickering typically means your paint job takes too long (say more than 10 msec), so it becomes visible to the human eye. Depending on what you have done several steps can be taken to improve it, maybe by a lot. Please explain more, and/or show the relevant code or pseudo-code.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I am make method read data from serial port and check plot if it valid or not regarding as some specifications ... if it valid i catch it and store message in arraylist and then read from arraylist to draw plots.
|
|
|
|
|
That is completely insufficient to judge whether you will have a painting problem or not.
There are a few categories:
1. Throughput
How many bytes do you need from your serial port to complete a drawing? what is the baud rate? is the peripheral sending full throttle, or does it need extra time to generate the data?
2. Plot
What do you need for plotting? is it some library that takes data points and generates an image, which you then paint? which library? how many data points? how big is the bitmap?
3. Organization
How do you structure this? Are you using the DataReceived event? if so, how and when do you transfer control to the GUI thread for painting.
Are you painting in the Paint handler?
Feel free to provide extra information if you think it may be relevant.
PS: take your time, I'm off now.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I am paste the code ... can you find the problem and help me ?
I Hope
|
|
|
|
|
Honeyboy_20 wrote: if it valid i catch it and store message in arraylist and then read from arraylist to draw plots.
This leads me to believe that your data read and drawing logic may be too closely coupled. Ideally they should be completely separate, executing in different threads.
When valid data is received, the data reader should fire an event (subscribed to by the UI) that causes the UI to simply invalidate its canvas, which in turn causes it to grab a copy of the data which it uses for purposes of rendering. You'll need to synchronize access in the grab operation.
Hope this helps.
/ravi
|
|
|
|
|
Here's the code
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.IO.Ports;<br />
using System.Windows.Forms;<br />
using System.Collections;<br />
using Microsoft.VisualBasic;<br />
<br />
<br />
namespace SerialPort16_5_2010<br />
{<br />
class ReviceDataFromSeriaLPort<br />
{<br />
#region Identifiers<br />
public SerialPort serialPort1 = new SerialPort();<br />
public TextBox txtDataRecived = new TextBox();<br />
<br />
private double range;<br />
private double azmouth;<br />
public ArrayList msgSequence = new ArrayList();<br />
#endregion<br />
<br />
#region Responsible for connect to serial port<br />
public void ConnectToSerialPort(string portname, Label lblMessage)<br />
{<br />
if (serialPort1.IsOpen)<br />
{<br />
serialPort1.Close();<br />
}<br />
try<br />
{<br />
<br />
serialPort1.PortName = portname;<br />
serialPort1.BaudRate = 9600;<br />
serialPort1.Parity = Parity.None;<br />
serialPort1.DataBits = 8;<br />
serialPort1.StopBits = StopBits.One;<br />
<br />
serialPort1.Open();<br />
<br />
lblMessage.Text = portname + " Connected";<br />
<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
}<br />
#endregion<br />
<br />
#region Responsible for Disconnect to serial port<br />
public void DisconnectToSerialPort(string portname, Label lblMessage)<br />
{<br />
try<br />
{<br />
serialPort1.Close();<br />
lblMessage.Text = portname + " Disconnected";<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
<br />
}<br />
#endregion<br />
<br />
#region Delegate and subroutine to update the TextBox control<br />
public delegate void myDelegate();<br />
#endregion<br />
<br />
#region updateTextBox funtionality<br />
<br />
int bytesLength=100;<br />
public void updateTextBox()<br />
{<br />
try<br />
{<br />
bytesLength = serialPort1.BytesToRead;<br />
<br />
<br />
byte[] comBuffer = new byte[bytesLength];<br />
<br />
<br />
#region Read Byte by Byte and check it.<br />
<br />
for (int BytesCounter = 0; BytesCounter < bytesLength; BytesCounter++)<br />
{<br />
int inputByte = serialPort1.ReadByte();<br />
string ConvertByteToHex = Conversion.Hex(inputByte);<br />
comBuffer[BytesCounter] = (byte)inputByte;<br />
<br />
#region Check if First byte in stream of bytes == 99<br />
if (ConvertByteToHex == "99")<br />
{<br />
if (BytesCounter + 1 < bytesLength)<br />
{<br />
int messageLength = serialPort1.ReadByte();<br />
comBuffer[BytesCounter + 1] = (byte)messageLength;<br />
#region Check if messageLength > 4 .. Check 3 probarity of message.<br />
if (messageLength > 4)<br />
{<br />
#region Check if messageLength == 4<br />
if (messageLength == 4)<br />
{<br />
<br />
}<br />
#endregion<br />
<br />
#region Check if messageLength == 10<br />
else if (messageLength == 10)<br />
{<br />
if (BytesCounter + messageLength <= bytesLength)<br />
{<br />
for (int msgByteCounter = 2; msgByteCounter < messageLength; msgByteCounter++)<br />
{<br />
int tempRecivedByte = serialPort1.ReadByte();<br />
comBuffer[msgByteCounter + BytesCounter] = (byte)tempRecivedByte;<br />
if (msgByteCounter == messageLength - 1)<br />
{<br />
#region check if message end equal '0d'='13'<br />
if (tempRecivedByte == 13)<br />
{<br />
<br />
string range1 = Conversion.Hex(comBuffer[msgByteCounter + BytesCounter - 6]);
string range2 = Conversion.Hex(comBuffer[msgByteCounter + BytesCounter - 5]);
string contactRange = string.Concat(range2, range1);<br />
range = Convert.ToInt32(contactRange, 16);<br />
<br />
string azmouth1 = Conversion.Hex(comBuffer[msgByteCounter + BytesCounter - 4]);
string azmouth2 = Conversion.Hex(comBuffer[msgByteCounter + BytesCounter - 3]);
string contactazmouth = string.Concat(azmouth2, azmouth1);<br />
azmouth = Convert.ToInt32(contactazmouth, 16);<br />
<br />
}<br />
#endregion<br />
}<br />
}<br />
MessageContents msgcontents = new MessageContents(range, azmouth);<br />
msgSequence.Add(msgcontents);<br />
<br />
<br />
<br />
}
}<br />
}<br />
#endregion<br />
<br />
#region Check if messageLength == 12<br />
else if (messageLength == 12)<br />
{<br />
if (BytesCounter + messageLength <= bytesLength)<br />
{<br />
for (int msgByteCounter = 2; msgByteCounter < messageLength; msgByteCounter++)<br />
{<br />
int tempRecivedByte = serialPort1.ReadByte();<br />
comBuffer[msgByteCounter + BytesCounter] = (byte)tempRecivedByte;<br />
if (msgByteCounter == messageLength - 1)<br />
{<br />
if (tempRecivedByte == 13)<br />
{<br />
}<br />
}<br />
}<br />
}<br />
}<br />
#endregion<br />
<br />
if (messageLength + BytesCounter < comBuffer.Length)<br />
BytesCounter += messageLength - 1;<br />
}<br />
else<br />
{<br />
}<br />
<br />
#endregion<br />
}<br />
#endregion<br />
#region do not read if first bytes not equal 99<br />
else<br />
{<br />
<br />
}<br />
#endregion<br />
}<br />
#endregion<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
<br />
}<br />
}<br />
#endregion<br />
<br />
#region used to Recive Data In Run Time <br />
public void DataRecivedInRunTime()<br />
{<br />
<br />
serialPort1.DataReceived += new SerialDataReceivedEventHandler(DataRecived);<br />
<br />
}<br />
#endregion<br />
<br />
#region DataRecived Event<br />
public void DataRecived(object sender, SerialDataReceivedEventArgs e)<br />
{<br />
txtDataRecived.BeginInvoke(new myDelegate(updateTextBox));<br />
}<br />
#endregion<br />
}<br />
}<br />
<br />
and MessageContents class to set range and azimuth on it
<br />
class MessageContents<br />
{<br />
<br />
public double msgRang;<br />
public double azmouth;<br />
<br />
public MessageContents(double _msgRang,double _azmouth)<br />
{<br />
this.msgRang=_msgRang;<br />
this.azmouth = _azmouth;<br />
}<br />
}<br />
in the form
----------------------------
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.Collections;<br />
using System.Drawing.Drawing2D;<br />
using System.Threading;<br />
<br />
namespace SerialPort16_5_2010<br />
{<br />
public partial class Form1 : Form<br />
{<br />
<br />
ReviceDataFromSeriaLPort rcvfrmSerial;<br />
ArrayList sequenceSore10 = new ArrayList();<br />
int x, y;<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
<br />
rcvfrmSerial = new ReviceDataFromSeriaLPort();<br />
rcvfrmSerial.ConnectToSerialPort("COM1", lblMessage);<br />
rcvfrmSerial.txtDataRecived = textBox1;<br />
rcvfrmSerial.DataRecivedInRunTime();<br />
}<br />
<br />
<br />
<br />
private void myCustomPanel1_Paint_1(object sender, PaintEventArgs e)<br />
{<br />
Graphics g = Graphics.FromHwnd(myCustomPanel1.Handle);<br />
Pen p = new Pen(new SolidBrush(Color.Red), 2.0f);<br />
<br />
g.TranslateTransform(400, 300);<br />
foreach (MessageContents item in rcvfrmSerial.msgSequence)<br />
{<br />
double range = item.msgRang / 100;<br />
double azimouth = item.azmouth;<br />
double range2 = item.msgRang + 1;<br />
x = (int)(range * Math.Cos(azimouth * Math.PI / 180));<br />
y = (int)(range * Math.Sin(azimouth * Math.PI / 180));<br />
g.DrawEllipse(p, (int)x, (int)y, 4, 4);<br />
this.Invalidate();<br />
this.Refresh();<br />
<br />
}<br />
}<br />
}<br />
}<br />
<br />
|
|
|
|
|
Hi,
I've been trying to read some of that code, which you made very hard by not using PRE tags. PRE tags exist for preserving formatting, mainly indentation, which facilitates seeing the structure of it all. So whatever you do in future, use PRE tags. You could even still edit your existing message and put PRE tags around its code.
The code itself looks horrible too. Here are some comments, the list is not complete:
1.
using Exception.Message rather than Exception.ToString() is stupid, as the latter offers much more information, making debugging a lot easier.
2.
You have a DataReceived event handler (fine), but all it does is use Invoke to force a delegate to execute on the GUI thread, so it actually is your GUI thread that will read all bytes from the serial port and interpret them. That is not smart, as it has no relation with the GUI at all. You should deal with the serial data in a handler (or a separate thread) and only invoke towards the GUI thread at the very moment you want to update the GUI.
3.
you read all serial port data one byte at a time; why not use SerialPort.Read(byte[] buffer, int offset, int count) to read all available data at once, then process it?
4.
you have lots of unnecessary conversions, from bytes to strings to ints and back. As your data is binary (I assume so, since you are reading bytes right now), why not always deal with it as bytes; and possibly once turning it into a string for displaying it if necessary.
5.
Get rid of those silly Conversion.Hex calls; they reek like Basic. If at all necessary, simply use byte.ToString("X2")
6.
I skipped some code, then saw a Paint method, with lots of mistakes.
A. use the Graphics you get from PaintEventArgs, don't create your own
B. don't call Invalidate() or Refresh() in a Paint handler. It is terribly wrong.
C. Avoid calling methods such as Math.Cos in a paint handler; you should have done that calculation beforehand and store it in your objects.
D. Dispose of the garbage you create; e.g. the pen
Conclusion: it is an abominable mess; I don't want to have another look at it, it should be binned and started all over.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|