|
Just write return and the function will end after executing finally block.
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore, Dream. Discover.
|
|
|
|
|
One suggestion from my side. If you put you connection inside a using block, you will not have to rely on any specific piece of code to close the connection and you can simply return from anywhere. It is the recommended way of doing the connection business.
This article will tell you how to use the connections with a using
ASP.NET - How To Use(Open/Close) Connections Correctly[^]
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore, Dream. Discover.
|
|
|
|
|
I know what happens to lock(x) in event of a Thread.Abort, what about "using"?
dev
|
|
|
|
|
UNIT CONVERSION APPLICATION:
Build a WCF web service (ConvertService) having following methods:
(a) GetUnits() method to retrive available units
(b) Convert() method to convert a measure from selected units handling errors (eg. attempt to convert inches to kilogram.. etc.)
(c) GetRatio() method returning a ratio used in conversion from/to selected unit
Should cover at least four units:
Mass and weight- Kilogram(kg) and pound (lb)
Distance and length - Kilometers(km), miles(mi), centimeters(cm) and inches(in)
Capacity and volume - litre(l) and gallon (gal)
Temperature - Celsius scale (C) and fahrenheit scale (F)
Create a WCF service client (ConvertClient) which windows form client having following interfaces which uses the WCF service
From(lbl): textbox (input) ----To(lbl): textbox (result)
UnitFrom(unit select + combobox) ------UnitTo(unit select + combobox)
<-->
(btn to switch)
Convert(btn) Ratio: textbox
Get Ratio(btn)
Thanks.
|
|
|
|
|
Temperature doesn't have a conversion ratio.
|
|
|
|
|
Thanks for the reply...
I would like to know What time would it take and what are your requirements (charge)?
|
|
|
|
|
You may be in the wrong forum. However, if you want me to do it for you it would cost $2,500 USD prepaid and it would be done in about an hour.
|
|
|
|
|
|
All Correct
|
|
|
|
|
MacRuturaj wrote: Thanks.
For what? It cannot be for answering your question, as there isn't one. We can help you with specific questions, but we don't do complete projects. CodeProject is a community, not a software vendor.
FWIW; you might want to reconsider the design. You can cover almost any unit by multiplying by the correct factor. Doesn't work for temperature though; easiest way was to add the multiplication-factors (and unit-names) to a table, and add in a formula that gets Eval uated for the temperatures.
Bonus-points if you can keep all your stuff in their respective SI-base units (so no kilometers or centimeters, only meters)
|
|
|
|
|
@Eddy Vluggen- I can understand that....
I posted this question because I saw some complete projects available for download on this website, I was looking through some material I can get and I found 2 softwares... so I thought I might get some answers like a software or a complete explanation with the code to make this small program.
|
|
|
|
|
The people who post articles do not read the forums every day. The reason we write those articles is because it's too much to explain "completely" in a post.
Here's an example in WinForms[^]; the article needs to be approved by the community, so it might not be visible today.
|
|
|
|
|
@Eddy Vluggen - " Thanks " for your interest and reply to this question. Even though it is not an answer I got some information from you.
|
|
|
|
|
You're welcome.
My apologies for the tone, but we see quite some people dropping the specs for their project here, and it's usually urgent. You'll get better results here simply by including a question at the end; "Anyone here got some bright ideas, tips or hints?"
Most members like to share their experience, even if it's not a specific question
|
|
|
|
|
Ya, you are right. I think codeproject website is different as this is my first question and the response I got was different too...
now the best way will be to learn it ... I was stuck at making the interface and logic for conversion with the error handling, so I posted the whole detail as a question to explain it clearly.
|
|
|
|
|
Hello,
I am using this free tool for all application logging.
Is there a way to control the growth of this log file? Meaning, a way to truncate after set number of days? Can I define this in the NLog.config file?
Thanks!
|
|
|
|
|
There is a section on size-based archival[^] in the NLog documentation. It might help you out.
|
|
|
|
|
File this under, it worked fine yesterday.
<br />
Uri uri = new Uri("http://ftp.nhc.noaa.gov/atcf/aid_public/");<br />
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);<br />
request.Timeout = 1;<br />
HttpWebResponse response = (HttpWebResponse)request.GetResponse();<br />
Yesterday, this code works fine. Today it doesn't. From what I can tell I think the IP address on the server has changed. When I remove the timout and wait, I can see that an incorrect IP address is being used. However, I can browse to the URL so the DNS is correct on my system (even command line tools resolve to the correct IP) I have tried flush DNS although, to be honest, there is no reason that should work, and it didn't resolve the issue.
So, I am left assuming that somehow, the .NET framework is caching an IP address somewhere. Now, I could reset the machine or clear all of the .NET temporary files but that would leave me with a temporary solution. What I need/want is someway to force .NET, via code, to always resolve the DNS and to not use any cached DNS (Assuming this is the error)
Also, if you have any troubleshooting suggesting that are "in-code" let me know. Rebooting, etc, is not an option because this will eventually be production code so it needs to be robust, I can't hold the hands of the application.
|
|
|
|
|
This is a two part issue. The root cause is a proxy server but this was masked by the following scenario:
The code base is shared between a Windows Forms application and an ASP.NET application. When I went from Windows Forms to ASP.NET I got the error. However, when I went back to Windows Forms, I still got the error leading me to conclude that the issue was not caused by ASP.NET. If I am to speculate, the persistence of the issue has to do with a secret cache by .NET, I cheated and cleared the System.Net.ServicePointManager internal service point tables but that did not resolve the issue, rebooting did however. So now that I knew the code worked in Windows Forms but not ASP.NET and sometimes not back-and-forth I had more to go on.
It seems that ASP.NET, does not use the PROXY servers configured for the local machine. My particular workstation uses a proxy configuration file and not a direct proxy so I had to research the proxy. When I use HttpWebRequest under windows forms the proxy is automatically used but when I use the HttpWebRequest under ASP.NET the proxy is ignored. With this little tidbit:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://ftp.nhc.noaa.gov/atcf/aid_public/");
request.Proxy = new System.Net.WebProxy(new Uri("my proxy server"));
Solves the issue. Overall this makes sense that it is a proxy issue, however, I would expect HttpWebRequest to behave in the same manner under both environments?
Last note, my above code will not work with an authenticated proxy, of course, but if anyone has a similar issue, good place to check.
Rant, why oh why, can't I get uniform consistent behavior and why must their be a myriad of "secret" configuration files that alter "consistent behavior" because, to be honest, I am certain the issue is not Windows Forms vs ASP.NET but secret (ok, not really secret) but numerous configuration files all conspiring to, by default, offer different behavior in the different environments.
|
|
|
|
|
In a C# 2010 windows application, I am using the following to connect to a sql server 2008 r2 database.
The app.configuration file looks like the following:
<connectionStrings>
<add name="DEVConnectionString" connectionString="Data Source=dev2008;Initial Catalog=DEV;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
The problem is once someone besides myself runs the application, it will not run correctly.
Thus I am assuming that the Integrated Security=True needs to be changed to a username and password that is setup for the
application to run.
Is my assumption correct? If not, would you be able to tell what I need to do so someone besides myself can run the application?
|
|
|
|
|
|
Setup a username and password as a security login in your sql database managemnet engine and then add that user as a security user in your specific database.
Then add the user id and password to your connection string
Everyone using your app will access the db as the same user though.
|
|
|
|
|
Your assumption is correct. Your windows domain must be added and given permission in SQL Server for Integrated Security to work. As a best practise, you should always create a dedicated database user specifically for your app and apply principle of least privileges to that user. For example, you would want your application to insert, update and delete rows from tables, but you wouldn't want you app to DROP tables or DROP the entire database itself. As a matter of fact, I have seen production applications using the built-in 'sa' account to access the database, which is really a security issue. Creating a separate user and streamlining its access also protects your database from vulnerabilities in your applications like SQL injection attacks.
|
|
|
|
|
Shameel wrote: As a best practise, you should always create a dedicated database user
specifically for your app and apply principle of least privileges to that user
For a client application.
A server uses a different idiom.
|
|
|
|
|
In a C# 2010 windows application, I am getting the following error message:
"The connection property in the Application Settings file is missing or incorrect. The connection string from the .dbml file has been used in its place".
I am also getting the warning message: warning CS0618: 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete,
it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings".
What I am trying to do is obtain the connection string information from the app.configuration file instead from the app settings file.
To accomplish this goal I am chanigng the *designer.cs to use the following code to obtain the connection string information:
base(ConfigurationManager.ConnectionStrings["DEVConnectionString"].ConnectionString, mappingSource)
The app.configuration file looks like the following:
<connectionStrings>
<add name="DEVConnectionString" connectionString="Data Source=dev2008;Initial Catalog=DEV;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
The above code works fine when I setup the code initially.
However once I reopen the soltuion file, I get the message listed above,
""The connection property in the Application Settings file is missing or incorrect.
The connection string from the .dbml file has been used in its place".
To solve this problem, I was trying to do the following steps:
1.Step 1: Right click on the .DBML file and select "Run Custom Tool".
2.Step 2: Set "Application setting = false" in the connecton properties of your DataContext.
3.Step 3: press "Save All".
The problem with the above solution is once I selected "Run Custom Tool", nothing happened. There was nothing for me to select.
Thus can you tell me and/or show me in code how to solve this problem?
|
|
|
|