|
sorry it's not working for me.how can i test ,whether it's working or not.
i kept that code in radiobutton_checkedChanged().and changed test-->tcpradio and blah-->true
in app.config
<appSettings>
<add key="tcpradio" value="0"/>
</appSettings>
plz help me
|
|
|
|
|
is it your windows application ?
Regards,
CodeBlack
|
|
|
|
|
yes it's windows application.vs2010 c# 4.0
|
|
|
|
|
Agreed on what Bernhard Hiller said. There are many options to achieve the same thing.
For example,
you can create a cookie and set value into cookie and define cookie expiration time Or
you can use the application data (AppData)folder. or
you can store it in database as well.
Store it in app.config only if there is no any other way.
Regards,
CodeBlack
|
|
|
|
|
If you want to change the values from your program, use settings - app.config is not the correct place for that.
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OtherLibs;
using CxCore;
namespace oneMoreTry
{
public partial class Form1 : Form
{
private CvCapture VideoCapture;
private IplImage frame;
private IplImage imgMain;
bool capture = false;
public Form1()
{
InitializeComponent();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
capture = true;
}
private void btnVideo_Click(object sender, EventArgs e)
{
double vidWidth, vidHeight;
VideoCapture = highgui.CvCreateCameraCapture(0);
if (btnVideo.Text.CompareTo("Start Video") == 0)
{
if (VideoCapture.ptr == IntPtr.Zero)
{
MessageBox.Show("badtrip ah!!!");
return;
}
btnVideo.Text = "Stop Video";
highgui.CvSetCaptureProperty(ref VideoCapture, highgui.CV_CAP_PROP_FRAME_WIDTH, 640);
highgui.CvSetCaptureProperty(ref VideoCapture, highgui.CV_CAP_PROP_FRAME_HEIGHT, 480);
highgui.CvQueryFrame(ref VideoCapture);
vidWidth = highgui.cvGetCaptureProperty(VideoCapture, highgui.CV_CAP_PROP_FRAME_WIDTH);
vidHeight = highgui.cvGetCaptureProperty(VideoCapture, highgui.CV_CAP_PROP_FRAME_HEIGHT);
picBoxMain.Width = (int)vidWidth;
picBoxMain.Height = (int)vidHeight;
timerGrab.Interval = 42;
timerGrab.Enabled = true;
}
else
{
btnVideo.Text = "Start Video";
timerGrab.Enabled = false;
if (VideoCapture.ptr == IntPtr.Zero)
{
highgui.CvReleaseCapture(ref VideoCapture);
VideoCapture.ptr = IntPtr.Zero;
}
}
}
private void timerGrab_Tick(object sender, EventArgs e)
{
frame = highgui.CvQueryFrame(ref VideoCapture);
if (frame.ptr == IntPtr.Zero)
{
timerGrab.Stop();
MessageBox.Show("??");
return;
}
imgMain = cxcore.CvCreateImage(cxcore.CvGetSize(ref frame),8,3);
picBoxMain.Image = highgui.ToBitmap(imgMain, false);
cxcore.CvReleaseImage(ref imgMain);
}
}
}
I have this code and when i step through the debugger to find the problem.
The problem i encounter is like this, it says that Cannot evaluate expression because a native frame is on top of the call stack.
when i break the debugger. the program stops at this point of the code. frame = highgui.CvQueryFrame(ref VideoCapture);
i dont know how to or what to revised in the code.
|
|
|
|
|
Hit F10 to step to the next statement in your code, and close any dialog boxes that have been opened by your code, and you'll be able to evaluate expressions.
|
|
|
|
|
i do what you said. but it didn't do anything.
the output of the screen captured from the webcam is still black screen only.
|
|
|
|
|
You need to step back out of the native code so the debugger will work. Try Shift-F11 which will step back out of the code you're in. You may have to do it several times, but eventually you'll return to to debuggable code.
|
|
|
|
|
i also try it. but when it returns to that. it is still black screen..
|
|
|
|
|
It looks like you're stepping into code you can't step out of. I'd guess it's your video-capture utility.
So just set breakpoints in your code, and only step into your own methods.
|
|
|
|
|
hmm i think it is on my code. or in the DLL's that i used in the code?
because when i breakpoints on some.
there is an error that goes like this.
System.AccessViolationException
|
|
|
|
|
hi,
i need to write custom elements in app.config. how to write it.
am developing UHFReader project.in that we r having TCP/IP and COM commections.
So I need to place IP,Port,Address and Interval(time setting to run the timer).in configuration file. plz help me how to develop it. and how to access that in my project.
|
|
|
|
|
Its easy to add these values to the configuration file.
<configuration>
<appSettings>
<add key="IP" value="Value1" />
<add key="Port" value="Value2" />
...
</appSettings>
</configuration>
You can even add your own whole new customized section to your file
<configuration>
<configSections>
<section
name="UHFConnectionSettings"
type="System.Configuration.DictionarySectionHandler" />
</configSections>
<UHFConnectionSettings>
<add key="Port" value="Value1"/>
...
</UHFConnectionSettings>
|
|
|
|
|
its ok but how to write the code in c# program. how to get them access
i have a form like:
TCP/IP(radio button) COM(radiobutton)
------------ --------------
port(textbox)
Port:(textbox) Baudrate(combobox with some values)
address(textbox)
IP:(textbox)
address(textbox)
open(button for COM) Close(button for COM)
open(button for TCP/IP)
close(button for TCP/IP)
Interval(textbox)
when i run the application application should be opened with previous values(means i run the application,then closed. after sometime or someother day if i run application ,that should come with previous values )
|
|
|
|
|
In the first case, try ConfigurationManager.AppSettings["Port"] .
In the second case, something like ConfigurationManager.GetSection("CustomSection"); would suffice.
|
|
|
|
|
am following second approach: i kept that statement at:
public Form1()
{
InitializeComponent();
ConfigurationManager.GetSection("CustomSection");
}
then i got the error like: ConfigurationErrorException was unhandled
Configuration system failed to initialize
plz help me
|
|
|
|
|
The only time I ever got this error was when I screwed up the XML in the app.config file.
|
|
|
|
|
thanq i got it. by using ur first approach.but now the problem is
i run my application-->selected one radio button -->then closed m application.
if i run my application next time ,that form should be opened by selecting the previous radio button. i need to store those values in app.config .how to store them dynamically in app.config
|
|
|
|
|
|
I am working with C# windows application. I have html source, which im converting to html element collection. I am parsing through each element and i want to get all attributes of particular element.
For eg: <input id="login" name="login name" class="login">
I want to dynamically fetch all the attributes of the above element like id, name, class.
Please help me on this.
|
|
|
|
|
If I were you, I would investigate using the HTML Agility Pack[^]. You will find it saves you no end of time working with HTML.
|
|
|
|
|
A simple token parser is decribed here[^].
There are tons more available on the internet.
You can even pay for some third party which will mean there is support provided as well.
|
|
|
|
|
I need a sample code to do an upload and download file from local machine to remote server using sftp or scp in genymed SSH2 . I am getting an exception "Cannot access a closed stream" while trying below code at get file method call, Connection is getting established successfully.
SCPClient Obj_SCP = new SCPClient(Obj_Conn); Obj_SCP.getFile(remotepath,localpath);
Obj_Conn.close();
|
|
|
|
|
how come adding "volatile" in below code snippet didn't help?
The output, without "volatile" would be like:
m=1,000,000, n=999,993
My expectation was, m=n=1,000,000 exactly if I added "volatile".
<br />
using System;<br />
using System.Collections;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Threading;<br />
using System.Threading.Tasks;<br />
<br />
namespace SimpleConsole<br />
{<br />
class Test<br />
{<br />
static int i = 0;<br />
<br />
static volatile int n = 0;<br />
static int m = 0;<br />
<br />
static Object SyncRoot = new Object();<br />
<br />
static void Main(string[] args)<br />
{<br />
Task[] Tasks = new Task[100];<br />
<br />
try<br />
{<br />
n = 0;<br />
m = 0;<br />
for (i = 0; i < 100; i++)<br />
{<br />
Task t = new Task(<br />
() =><br />
{<br />
for (int j = 0; j < 1000000; j++)<br />
{<br />
n++;
<br />
lock (SyncRoot)<br />
{<br />
m++;<br />
}<br />
}<br />
}<br />
);<br />
<br />
Tasks[i] = t;<br />
<br />
t.Start();<br />
}<br />
<br />
Task.WaitAll(Tasks);<br />
Console.WriteLine("n=" + n + ", m=" + m);<br />
<br />
Console.WriteLine("Hit any key to exit");<br />
Console.ReadLine();<br />
}<br />
catch (Exception Ex)<br />
{<br />
Console.WriteLine("Error in main: " + Ex.Message);<br />
}<br />
<br />
return;<br />
}<br />
}<br />
}<br />
dev
|
|
|
|