|
Yes.
The only thing is you must make sure you check the values returned; it would be very
wrong to ignore an error code, that is one of the very good reasons to use exceptions
in general, return codes in special cases only.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Just throw the Exception, it allows you to easily provide additional information about the problem.
|
|
|
|
|
There's a lot of ways to check for errors. Exceptions are probably the last line of defense against bad stuff coming into your code. And they should be used as part of defensive programming.
At some point in your code, you need to figure out what to do about some problem otherwise the user in confronted with something like "Invalid parameter something in somemethod" which is probably not a positive user experience.
It is a good idea to catch input errors as soon as possible. The .NET framework provides this functionality with validators. You can attach a validator to a user control and check the input values long before an exception would be even necessary. You might want to look at An Introduction to Validation Controls[^]. The .NET Framework provides several built in controls to do basic validation for both ASP.NET and Windows Forms.
You can also build your own validators as shown in Validator Control Samples[^].
In addition the Validation Application Block[^] will provide a way to declare your validations without a lot of code. The Enterprise Library Validation Application Block provides a library of classes, called validators, that supplies the code for validating .NET Framework data types. For example, one validator checks for null strings and another validator checks that a number falls within a specified range.
Exceptions are really important for you to use in keeping your code clean and to define the expectations that your code has to anyone who is calling your method. But you should do validation on user input too to weed out any bogus values before they get to your code.
But let's say that your code does get into a bizarre state that you did not anticipate. And that the code throws one of those exceptions. You'll want to figure out what to do about it so that your users or system engineers can understand the problem and fix it. This means that ultimately you should catch your exceptions and provide yourself and your IT department with instructions that are actionable, either in a log file or in a user error message. You should provide the user with some way to fix the problem.
Exceptions are just the first part to writing your program so unexpected values don't break it. And you should catch all your exceptions to provide your user with something other than, "Oops. Something unitelligible failed."
Find more support for your software development efforts at Innovate-On[^]
|
|
|
|
|
HI All,
I HAve Added Web Reference to A VC.Net (VisualC++/CLR) Project.
After I Have added Successfully a Web Reference.I Have to Change the
URL Behaviour Property to "Dynamic" but I Havent Found Such Property of
Web reference.
IF we Add A web reference to C# project & Open The Propertied Dialog Box
of Web reference ,It will Show U A property "URL Behaviour" Where we can Change Dynamic or Static.
But for CLR Projects I Havent seen That property.
plz suggest me is there is a method where i can Change the URL Behaviout to Dynamic.
Thank You
Nagaraju
|
|
|
|
|
Hi,
I have created a COM Visible .NET dll that is deployed on a Citrix server (regasm.exe). What the dll does is that it calls a web service on a remote machine.
Everything works fine running as an administration, but running as a "normal user" the COM Client can´t create the .NET dll.
What could be wrong? Could it be a sequrity issue?
Br,
Jonas
|
|
|
|
|
Did you put it in the GAC?
|
|
|
|
|
Is it possible to get code comments included in the generated WSDL file ?
|
|
|
|
|
Hi,
I have a .net application that does a lot of number crunching and I run it on a 64-Bit machine with quad CPU. The machine has 4GB RAM.
When I compile the application to explicitly target x86 machine the application runs faster than when I compile it to target x64 machine. The difference is around 50% !!!
I don't change anything in the application except the target machine.
The application is a pure .net application.
Any idea, what is the reason for this?
Ami
|
|
|
|
|
Hi,
can you tell more about your app, what it is doing, what the most common data types are?
why would you expect it to run faster? is your data basically 64-bit wide? 32-bit? 16-bit?
is it text processing?
what language are you using?
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi,
The common type is double, which is 8 bytes long.
The application does a lot for number operations (simple adding, multiplying, etc.)
I expect the x64 version to run at least as fast as the x86 version.
I am using C#.
Ami
|
|
|
|
|
Hi Ami,
assuming the calculations outweigh the memory transfers and general program flow,
I expect no difference whatsoever between a 32-bit and a 64-bit version of your app:
they both will spend their time mostly on processing 64-bit data that sits in the
float registers and/or the data cache.
So if your 64-bit app is slower, something definitely is wrong. Are you comparing equal
things (e.g. both release builds, identical jobs)?
If you have been trying to optimize things by using multiple threads, then maybe the two
systems you compare are not equally happy about your threading approach. If this applies,
it has to be looked at more thoroughly... As a first measure, you could reduce to one thread
and compare these (again expecting equality).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi Luc,
Luc Pattyn wrote: So if your 64-bit app is slower, something definitely is wrong. Are you comparing equal
things (e.g. both release builds, identical jobs)?
It is the exact project (Release mode), the only difference is the target CPU x86 or x64.
Luc Pattyn wrote: If you have been trying to optimize things by using multiple threads, then maybe the two
systems you compare are not equally happy about your threading approach. If this applies,
it has to be looked at more thoroughly... As a first measure, you could reduce to one thread
and compare these (again expecting equality).
I am using some multithreading, I'll try to do it in one thread and check the results.
Thanks for the advice.
Ami
|
|
|
|
|
Just wanted to know if shutdownTimeout has any edge over the traditional executionTimeout at least with respect to ASP.NET.
I have my application wait for a slow network response. But sometimes when the servicing network is slow, the front-end web application goes astray. Here is my query:
Can I be able to keep my ASP.NET worker process alive in a particular session from within ? I am sure that one possible reply would be that this would open up loopholes for hackers to break into. But I can ensure that this code resides well within a httpmodule and parsed only one genuine needs.
|
|
|
|
|
Have you resolved this?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I'm going to bind data set to combo boxes. Data set is compound from 2 tables and joined by relation. The declaration is as follows:
Private tablePRAgent As PRAgentDataTable<br />
<br />
Private tablePRAgentLocation As PRAgentLocationDataTable<br />
<br />
Private relationPRAgentPRAgentLocation As DataRelation<br />
The table PRAgentDataTable has main rows with details in table PRAgentLocationDataTable . So first combo is bound to PRAgentDataTable and second - to PRAgentLocationDataTable , by relation. Filling adapters (and in consequence combos) while I add clause "WHERE col=@parameter" ends with "exception of type 'System.Data.ConstraintException'". When there is no WHERE clause everything goes right.
How could I overcome this problem?
|
|
|
|
|
Hello,
I have created a DLL with
signed key , com visibility is true and registered it with regasm but still when i try to use it in ASP page by calling server.createobject() i can not use.
Please suggest.
Pavas
|
|
|
|
|
Ha anyone converted the NCrypto library to .Net 2.0?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Any luck at converting it?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Nope - I had to move on at work.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hey all
I'm developing an .NET application (C#) which hosts a WebBrowser control. The WebBrowser contains a Java Applet. I'm experiencing serious problems with ComboBoxes in this Java Applet. It seems like the comboboxes don't respond to mouseclicks. I can open the dropdown list, but I can't select any items. If I instead use the keyboard it works perfectly...But that's just not good enough
If I open the Java Applet in a "standalone" browser everything is peachy...
Has anyone experienced this ?? And maybe even got a solution ? :-P
|
|
|
|
|
Greetings,
I am having C# project that make the Executable also. The system use over 20 users' machines. Currently I installed the exe indidual machines coping the source and it is tedious task to do! When i have to do any modification in existing, then again i have to make the setup.exe and installed individual machine.
Are their any way to do this task simple? like one VB.exe(in share folder in LAN), create shortcut and running ncely noh! like that!!!
Any learning resources, plz send me!!! U r Welcome!
Thanks in advance!
|
|
|
|
|
Take a look at ClickOnce, you can install the application onto their machines using this but it'll automatically check for updates and download and install them if configured to do so.
|
|
|
|
|
http://www.15seconds.com/issue/040121.htm Read this article this ll help you a lot. This article is about .net code access security
best regards,
krishna
|
|
|
|
|
Does anybody know how to organize dialog between 2 sites?
For example, site1 sends a message to site2. Site2 recieves the message and sends "The message was recieved"
|
|
|
|
|
Hi all,
suppose the current application is running in ur version 1.0.0.3 and now u are required to use new version 1.0.0.4 .
Now i need to know where can i make the changes i.e for the update to effect
in GAC or Application's web.config
Can anyone suggest me the answer
Thanks
kumar
|
|
|
|