|
Imtiaz Murtaza wrote: So what you guys suggest me in such cases. Shall i continue to throw generic "Exception" or use InvalidOperationException ? Or is there better solution ?
Thumb rule, do not follow blindly: If the calling code needs to perform a special function on encountering this specific error situation, use a custom exception class. If you are simply logging the message, displaying a dialog to the user, etc, and the only thing that changes is the error message, use System.Exception.
Cheers,
Vıkram.
I've never ever worked anywhere where there has not been someone who given the choice I would not work with again. It's a job, you do your work, put up with the people you don't like, accept there are probably people there that don't like you a lot, and look forward to the weekends.
- Josh Gray.
|
|
|
|
|
Hi Imtiaz,
My suggestion would be , you can group up the types of exception in our applicaion and create a custom exception class for each group , for Example all the exception related to color can be grouped into an exception class called 'InValidColorChoiceExpection' than it does not matter if it is a sky color or any other exception related to color , you may not create a individual exception class for each exception, the point here to to properly Categorize the exceptions , in some case you may use the inbuilt .net Exception classes , for example if there is invalid Operation performed , you may not require to Create something like 'CustomInValidOpreation' , there is already an exception for it.
So in short, group you exception , try to fit it in a group that already exist , if not then only go for a new custom exception class.
I hope i am understandable
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
hiii
In this Case u can use Exception()...
|
|
|
|
|
how can I join Transaction 1 and 2?
<br />
IDbTransaction oTran1 = oConn1.BeginTransaction();<br />
obj1 = new SomeObj(oConn1);<br />
obj1.DoWork();<br />
<br />
IDbTransaction oTran2 = oConn2.BeginTransaction(); <br />
obj2 = new SomeObj(oConn2);<br />
obj2.DoWork();<br />
<br />
oTran1.Commit();<br />
oTran2.Commit();<br />
I want to do something like:
<br />
oTran2.Join(oTran1);<br />
Thanks
dev
|
|
|
|
|
You want that both transactions to be in a single transaction scope? If yes, TransactionScope[^] class will help.
|
|
|
|
|
Many thanks - is this Microsoft SQL Server specific though?
dev
|
|
|
|
|
No it will work with all providers who supports transactions. I have used it with SQL server and Oracle. Using it with Oracle requires Microsoft transaction service for oracle to be installed.
|
|
|
|
|
i am new in programming, i want to know ,how is java, is it very difficult than c# & C++?what is her ranking..how much is it difficult?
, what is client side language & databases for java?
& what is her technology like asp.net for c# for web based ?
thanking you
|
|
|
|
|
|
|
waqarnaeem2@hotmail.com wrote: is it very difficult than c#
I don't think so. But I felt JAVA is more verbose than C#.
waqarnaeem2@hotmail.com wrote: what is her ranking
|
|
|
|
|
When I was first reading about C# (circa 1999) someone said, "Isn't that the new Microsoft Java?"
|
|
|
|
|
Isn't it?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Java is more like C# and C# is more like Java. They share lot of common concepts. both are pure object oriented, and if you know C# it isn't difficult to learn Java. I can recommend "Head First Java" an excellent book from o'reilly to start with Java.
Sometimes Java framework like SOAP, EJB etc would scare you but once you are good with BASIC Java, Life would be much easier with them.
As far as you are concerned about the databases you can use any kind of database with Sun's ODBC drivers (just google to find them). And if you are looking to make a web application, You will need to know JSP (Java server pages, 99% like Java) and Servlets. JSP is client side and Servlet is server side scripting language.
I was a Java programmer, and I learnt C# with easy. Code project was always the best friend.
Happy learning,
Karmendra
|
|
|
|
|
Hello all,
how to configure trace listener to output trace statements to command window?
Thanks.
|
|
|
|
|
You have a custom listener in console application? If that's the case, just use Console.WriteLine.
|
|
|
|
|
its a windows application project where i want to configure tracelistener to output trace statements to command window. I have already sprinkled trace.writeline statement all over project and configured TextTraceListener, which outputs trace statements to text file.
|
|
|
|
|
As far as I know there's no 'native' support for that in framework, so I guess you should
- create a console application
- start a new process for that application
- use IPC to receive data from you trace listener
- write it to console
|
|
|
|
|
Hi Mika,
So, you mean:
1. If i configured Text trace listener to log statements to file say "TraceFile" under c:
2. The console application should watch that file ("TraceFile").
3. And if there are any changes to that File , get it and write it to console. (your way is IPC but i am thinking of FileWatcher control)
am i on right track?
Thanks.
|
|
|
|
|
Yes, you can do it that way also. When the file changes, you just have to know what lines are already written to console and write the new ones. Hopefully the FileSystemWatcher doesn't miss modifications if you're reading the file and it's modified at the same time. Also make sure that you don't lock the file while reading so that the listener is unable to write to it.
|
|
|
|
|
|
Member 2324483 wrote: am i on right track?
I don't think so. If you need the trace statements displayed in the command window, why to write it to a file and watch it? TextWriterTraceListener class has a constructor overload which takes TextWriter type. To output the trace to command window, follow the below steps.
1 - Goto project properties and change your project type to console application. This will start a command window with your form.
2 - Add the following code in the main .
static void Main() {
TextWriterTraceListener listener = new TextWriterTraceListener(Console.Out);
Trace.Listeners.Add(listener);
Application.Run(new YourStartupForm());
} You can see the Trace.WriteLine is writting to the command window.
|
|
|
|
|
Actually, i don't want to change my project type to console application. Its a product and i want to show trace output in separate window when it is enabled.
|
|
|
|
|
Hey,
im currently developing an application, one of the features of the app is that it creates
pdf files, but i want the files to be saved in a sub directory of where the application is
installed, but how do i code that?
thanks
|
|
|
|
|
You can use System.Reflection.Assembly.GetExecutingAssembly().Location . Just remove the application name part to get the directory portion and then add the subfolder you need.
|
|
|
|