|
|
Please Ignore this post
Well.. It depends on how you are using the following code snippets...
public class ReturnExample
{
private String normalExecution()
{
String result = "";
try
{
result = "Entered try block.";
return result;
}
catch(Exception e)
{
result = result + "Entered Catch block.";
return result;
}
finally
{
result = result + "Entered finally block.";
}
}
public static void main(String[] args)
{
ReturnExample example = new ReturnExample();
String result = example.normalExecution();
System.out.println(result);
}
}
Here you will find the reaturing value is updated;
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Well.. It depends on how you are using it. look at the following code snippets...
public class ReturnExample
{
private String normalExecution()
{
String result = "";
try
{
result = "Entered try block.";
return result;
}
catch(Exception e)
{
result = result + "Entered Catch block.";
return result;
}
finally
{
result = result + "Entered finally block.";
}
}
public static void main(String[] args)
{
ReturnExample example = new ReturnExample();
String result = example.normalExecution();
System.out.println(result);
}
}
Here you will find the reaturing value is updated;
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Oh, yeah, there is that; but it's easily avoided by not writing that way.
I suppose a better position is simply to avoid return in catch and finally blocks, but allow them in try blocks as long as there are no returns outside the try (the catch must rethrow).
In fact it may be better as an argument for the Single-Return Brigade.
|
|
|
|
|
First you said.
Here you will find the reaturing value is updated;
result = "Entered try block."!
So what's wrong with this?
At next I said try and finally and not try and catch.
And whats the difference between try finally or using?
Both do the same!
Now to your statement "its not a good practice".
Whats wrong with the practice to cleanup everything
you allocated in an function?
Now one question:
Ever seen the limitations of the garbage-collector?
So it can be a good practice to collect the generation
zero (objects with a short lifetime cycle) in a
finally statement, if your objects eats up a large amounts of
memory, or the gc kills your performance!
At last one word to those crying out never catch something till the
exception reaches the gui layer.
This is wrong in general. Its right that you should not catch
everything and send it to nirvana but how about this? (pseudocode)
ConnectionObject con = null;
TransActionObject trans = null;
try
{
con = new ConnectionToSomeDatabase(...);
trans = new TransActionObject(con, ...);
trans.Commit();
trans = null;
}
catch
{
if(trans != null)
trans.Rollback();
throw;
}
finally
{
if(con != null)
con.Close();
}
How to implement something like this?
Whats the point not to use the given possibilities?
If somebody now says, its slow, then you are right
if you use this in a very fast loop, but how about
start a transaction on a database? There is not
comparision!
So just my 2 cent on this.
And yes I will continue make intensive use of this kind of
statements!
Greetings
Covean
|
|
|
|
|
Hi all. Does anyone have any experience deploying a .nunit file to a network share?
I'm trying to share everything involved with running a particular test suite such that anyone on the team can simply access the share, open my nunit file in their NUnit-gui and run to see my status. The test suite that is to be shared is not dependent upon executing any custom code. Every one of the tests is structured similarly to this:
[TestFixture()]
public class CoverageTests
{
[Test()]
public void ReportStatusOfTask1()
{
Assert.IsTrue(false, "Task 1 has not begun yet");
}
[Test()]
public void ReportStatusOfTask2()
{
Assert.IsTrue(true, "Task 2 is ready for review");
}
}
"I need build Skynet. Plz send code"
|
|
|
|
|
Hello Dear Friends,
I've an application which shows the video from the webcam.
I want to create a C# application which can capture the part of the first application that shows the video in it. Can anybody suggest the way to do this. One way to do this is as described below
1) From the first running application that shows the video in it we can get handle of the window and from that window handle we can get the left,top, right,bottom of the area of the application that shows the video. I've HWND of the first running application but how do I get the left,top,height,width of the area which shows the video.
Is there any other way to achieve this or suggestion for this.
Thanks in Advance,
ritz1234
|
|
|
|
|
you need the handle of the control that shows the video or calculate the correct region if you know the correct location of the "videocontrol"..
greetz
|
|
|
|
|
Hi rootjumper,
Thanks for the response.
The problem is that it is the SKYPE which shows the video while we do the video call.And I don't think it use any control for the video so how to get the handle of the region or the location of the video region?
Thanks
ritz1234
|
|
|
|
|
Hi,
I am developing a C# app in which i want to use PIV Middleware but VS didn't accept its dll when i tried to make a reference. I don't have much experience in this type of programming, can some one guide me and refer to some sample codes or articles.
Thanks in Advance
shezi
|
|
|
|
|
Hello,
Could you please explain me how to put icons to the buttons of Windows application? And also I am tryting to put icon to application itself..
All the best
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:17am.
|
|
|
|
|
thank you for the information, one more question what about putting icons instead of buttons?
|
|
|
|
|
I have a ListView control with a column(just for temp. test) and 2 Groups.
Now, the LV getting populated with 10 items(0..9) and associated with first group in ListView. Now when all done, I'm iterating the Items collection. And found it same as appearing in ListView.
http://img40.imageshack.us/i/40225142.png/[^]
private void Form1_Load(object sender, EventArgs e)
{
for (int a = 0; a < 10; a++)
{
ListViewItem lvi = new ListViewItem(a.ToString());
listView1.Items.Add(lvi);
listView1.Groups[0].Items.Add(lvi);
}
}
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
for (int a = 0; a < listView1.Items.Count; a++)
{
richTextBox1.Text += listView1.Items[a].Text + "\r\n";
}
}
now, When I set its sort to Descending...it appears like this
http://img39.imageshack.us/i/43854370.png/[^]
In the above screenshot, the indexes are accurate but its showing '9' at the end.
So I thought to add/insert items manually without using inbuilt sorting. And I did but problem persists. Its showing in the sequence the items added/inserted. However the indexes are correct. Any idea guys ?
I also tried ListView.RedrawItems() but nothing seems to works.
Edit : Found something...but View is already set to Details
http://www.codeproject.com/Messages/2509769/Bug-in-ListView-Items-Insert-int-ListViewItem.aspx[^]
Finally Edit 2 :
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=115345[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
modified on Tuesday, November 10, 2009 8:00 AM
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:18am.
|
|
|
|
|
thats not exactly the problem...its a bug
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=115345[^]
anyway, I'll try that guy's method
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:17am.
|
|
|
|
|
I have same
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Good morning.
I was wondering if anyone has come across this anomoly.
I have code to populate a WebBrowser control based on the folder address (e.g. C:\). This code works well and is as follows:
private void cboFolder_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboFolder.SelectedIndex != -1)
{
Cursor.Current = Cursors.WaitCursor;
SetProgressBarMarquee();
lblLoading.Visible = true;
progressBar1.Visible = true;
Application.DoEvents();
this.viewToolStripMenuItem.Enabled = true;
cboSP_Site.SelectedIndex = -1;
cboWS.SelectedIndex = -1;
txtAddress.Text = cboFolder.SelectedValue.ToString();
WebBrowser1.Url = new Uri(cboFolder.SelectedValue.ToString());
}
}
private void WebBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
SetProgressBarContinuous();
lblLoading.Visible = false;
progressBar1.Visible = false;
Cursor.Current = Cursors.Default;
}
I used some code to set up the different folder views from the view menu. Everything seems to work well, but when I try to switch to details, the web browser window go blank until I right click and then it appears. Also periodically, the folder icons will not show up.
Any suggestions? Thank you, WHEELS
modified on Tuesday, November 10, 2009 8:01 AM
|
|
|
|
|
Hi,
I need to create ASP.net application which can convert Office 2007 Word document(*.docx) file to PDF document. Application has constraint as below,
1. Office 2007 is not installed on web server. (Server which is going to host ASP.net application.)
2. Web server will have Window 2003 installed.
3. Web server has Framework 2.0 installed.
Can anyone suggest me how to convert document into PDF with describe limitation.
I appreciate if anyone suggest third party DLL(Paid or Free) which can do that.
Thanks,
Mayur Patel
|
|
|
|
|
|
Thanks Russ.
I will check it.
Mayur Patel
|
|
|
|
|
|
|
high guys
i have a problem
when i press F5 on visual studio to start debugging of my project, it runs good no errors
but
when i press ctrl+F5 on visual studio to start without debugging of my project,it gets error message
the error message is:
Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immedediately.
the type initializer for 'System.Data.SqlClient.SqlConnection'threw an exception.
Details..
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception. ---> System.PlatformNotSupportedException: This operation is only supported on Windows 2000 SP3 or later operating systems.
at System.Security.Principal.SecurityIdentifier..ctor(WellKnownSidType sidType, SecurityIdentifier domainSid)
at System.Diagnostics.SharedUtils.EnterMutexWithoutGlobal(String mutexName, Mutex& mutex)
at System.Diagnostics.SharedPerformanceCounter.GetCounter(String counterName, String instanceName, Boolean enableReuse, PerformanceCounterInstanceLifetime lifetime)
at System.Diagnostics.SharedPerformanceCounter..ctor(String catName, String counterName, String instanceName, PerformanceCounterInstanceLifetime lifetime)
at System.Diagnostics.PerformanceCounter.Initialize()
at System.Diagnostics.PerformanceCounter.set_RawValue(Int64 value)
at System.Data.ProviderBase.DbConnectionPoolCounters.Counter..ctor(String categoryName, String instanceName, String counterName, PerformanceCounterType counterType)
at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String categoryName, String categoryHelp)
at System.Data.SqlClient.SqlPerformanceCounters..ctor()
at System.Data.SqlClient.SqlPerformanceCounters..cctor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlConnectionFactory..cctor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlConnection..cctor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlConnection..ctor()
at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
at Computer_Sales_System.Form2.button1_Click(Object sender, EventArgs e) in D:\My first project\Computer Sales System\Computer Sales System\Form2.cs:line 178
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3074 (QFE.050727-3000)
CodeBase: file:----------------------------------------
Computer Sales System
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3074 (QFE.050727-3000)
CodeBase: file:----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3074 (QFE.050727-3000)
CodeBase: file:----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3074 (QFE.050727-3000)
CodeBase: file:----------------------------------------
PresentationCore
Assembly Version: 3.0.0.0
Win32 Version: 3.0.6920.1500 built by: QFE
CodeBase: file:----------------------------------------
WindowsBase
Assembly Version: 3.0.0.0
Win32 Version: 3.0.6920.1500 built by: QFE
CodeBase: file:----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3074 (QFE.050727-3000)
CodeBase: file:----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3074 (QFE.050727-3000)
CodeBase: file:----------------------------------------
WindowsFormsIntegration
Assembly Version: 3.0.0.0
Win32 Version: 3.0.6920.1500 built by: QFE
CodeBase: file:----------------------------------------
PresentationFramework
Assembly Version: 3.0.0.0
Win32 Version: 3.0.6920.1500 built by: QFE
CodeBase: file:----------------------------------------
PresentationFramework.Aero
Assembly Version: 3.0.0.0
Win32 Version: 3.0.6920.1500 built by: QFE
CodeBase: file:----------------------------------------
System.Management
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3074 (QFE.050727-3000)
CodeBase: file:----------------------------------------
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3074 (QFE.050727-3000)
CodeBase: file:----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
the code is:
SqlConnection cn = new SqlConnection(@"Data Source='MOHAMEDEWEHISHY\SQLEXPRESS';Initial Catalog='Computer Sales System';integrated security=sspi");
try
{
SqlCommand cmd = new SqlCommand("backup_database", cn);
cmd.CommandType = CommandType.StoredProcedure;
if (System.IO.File.Exists(@"D:\SQLServerBackups\Computer Sales System.bak"))
{
System.IO.File.Delete(@"D:\SQLServerBackups\Computer Sales System.bak");
}
cn.Open();
int i = cmd.ExecuteNonQuery();
if (i < 0)
{
MessageBox.Show("Your database is backed up successfully");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
MessageBox.Show("Sorry ... You can not back up your database");
}
finally
{
cn.Close();
}
so the problem is using SqlConnection with others not DML commands
i tried to use OLEDBConnection but it not gets result
So what is the solution????????
Thanks,
Mohamed El-Wehishy
|
|
|
|