|
My setting is Debug Info=pdb only
but it does not work
Gurpreet
|
|
|
|
|
Hmm, I take it that the PDB's are in the same folder as the dll?
What specifically isn't working?
When I run your code I get the following output (I inserted a Environment.Newline):
Debug:
ThreadHelper.ThreadStart()
ExecutionContext.Run()
HostProc.RunUsersAssembly()
AppDomain._nExecuteAssembly()
Program.Main()
Program.MyFunc()
Program.GetCallStack()
Release (with PDB)
ThreadHelper.ThreadStart()
ExecutionContext.Run()
HostProc.RunUsersAssembly()
AppDomain._nExecuteAssembly()
Program.Main()
Program.MyFunc()
Program.GetCallStack()
|
|
|
|
|
Here is my output (RUN IT VIA COMMAND PROMPT AND NOT F5 in Visual Studio)
C:\Applications\poc\ConsoleApplication1\ConsoleApplication1\bin\Release>consolea
pplication1
Program.Main()Program.GetCallStack() --
C:\Applications\poc\ConsoleApplication1\ConsoleApplication1\bin\Release>cd..\deb
ug
C:\Applications\poc\ConsoleApplication1\ConsoleApplication1\bin\Debug>consoleapp
lication1
Program.Main()Program.MyFunc()Program.GetCallStack() --
NOTE : - Program.MyFunc() is missing in release mode.
Gurpreet
|
|
|
|
|
Anyone has any information on this? Its bit urgent!!
Gurpreet
|
|
|
|
|
I've run the code from command prompt and you're right. I believe that this is a compiler optimisation as MyFunc is so simple. If you run the following code:
static void Main(string[] args)
{
MyFunc();
Console.ReadKey(false);
}
public static void MyFunc()
{
Console.WriteLine("Begin");
Console.WriteLine(Program.GetCallStack());
Console.WriteLine("End");
}
public static string GetCallStack()
{
System.Diagnostics.StackTrace callStack = new
System.Diagnostics.StackTrace();
string s = "";
int index = 0;
while (true)
{
System.Diagnostics.StackFrame frame =
callStack.GetFrame(index);
if (frame == null) break;
System.Reflection.MethodBase method = frame.GetMethod();
if (index == 0) s = " --" + s;
s = method.DeclaringType.Name + "." + method.Name + "()" + Environment.NewLine + s;
index++;
}
return (s);
}
You should get the following output:
Debug:
Begin
Program.Main()
Program.MyFunc()
Program.GetCallStack()
--
End
Release (with PDB):
Begin
Program.Main()
Program.MyFunc()
Program.GetCallStack()
--
End
|
|
|
|
|
Thanks this works!!
Gurpreet
|
|
|
|
|
|
You can try:
[MethodImpl(MethodImplOptions.NoInlining)]
In the method that is disappearing.
|
|
|
|
|
Hi
Is there a way to convert .flv to .WMV file using C#? Please advise.
Thanks
Jawad Khatri
|
|
|
|
|
|
Hi everyone,
Today I am highly unpleased about a matter and that is "Test Driven Development". I just want to share my idea with you and want to hear back from you if what I am thinking is right or wrong. Also would like to hear about your idea.
Last few days, I am highly studying about Test Driven Development and to me, it sounds like, there is a magical framework which will allow me to run automated Unit Tests on methods I write. OWE, that can be awesome. I can only just dream about it. But when I wanted to practice, I realized that, it is not applicable to any of the project I have developed so far. What a weired. The articles and books tells me lots of benefits about Test Driven Development, like, 'You will get confidence when you write code...etc...blah blah blah..' But I dont think it is now unknown to any developer. To my thinking, almost all developers develop some kind of test project to test the application he/she is developing. So, what is really irritating me is, I have following Projects:
1. WinForm Custom Control.
2. ASP.NET WebForm Custom Control.
3. ASP.NET Web Application.
4. Windows Form Application.
5. Some Class Libraries in C#.
Ok, Now, I started to apply TDD to WinForm Custom Control and ASP.NET Custom Control which is purely UI oriented. Now, I found that, TDD is not good for UI. It is really not possible to automate the test on my control for some weired activities done by my user. I need to manually do something using Mouse/Keyboard to generate a problem and then, write solution to that problem. Yeah, I read there are some very very complex frameworks for testing UI, but I believe those are all commercial advertisement, not a developer friendly framework.
Then, I tried to apply VS integrated Unit Test feature to test my ASP.NET Web Application, Alas, it is sooo rigid that, I can test only if the user clicked a button or not. I wanted to test to simulate Login, But I found I cannot provide password to the Login Control and then, I gave up. Also many many limitations are there, I cannot test what I really worry about.
Then, I tried on Windows Form Application, again, same problem. Windows Form is highly UI oriented. Some of the experts are telling me that, I should not test UI. Rather, I should separate the UI from Business logic and test only Business Logic. Well, I thought, ok, lets try to test the Business Logics, when I separated my UI from Business Logic, I did not find really much code there. Because, Business logics are somehow related to UI. Anyway, of course it is my OOP practice that my Business logic code which is not used outside of the scope, I create them as private methods. So, I found that, TDD cannot test Private Methods. Hell!! then, what I gonna test ? I searched the google and found some article where someone is telling that, 'Private methods are AntiPattern' HUH!!! ? Just because TDD cannot be used, so now I will have to forget about OOP principles of encapsulation and think that, private methods are AntiPattern !! Now, I will have to make all my methods public which gonna clash with names ...one with another... ? I really got irritated to read that. The writer in that article wrote that, " I can bet, most of your private methods can be written as public "!! I was really angry to read that . Yeah, well, if I just change all the methods from private to public then, yes, my application wont break, but then ? is that the way I can maintian my project ?
Finally I found it useful, only if I develop an algorithm like 'Search', 'Sort' etc which does not have anything to do with UI and Website, Session etc, then, yes, I can use TDD. I dont know, unless I create an enterprize application, I wont find any really big algorithm development project. So, I am asking your opinion. What do you think about it ?
Thanks for your time reading this post.
Regards.
|
|
|
|
|
I've always found TDD to be best with algorithm based stuff like you've found.
With any unit testing life becomes much easier if you make sure that you pass in any requeres values as parameters into the method your testing so that you don't rely on having a populated Session, or HttpContext.
Private methods as an Anti-pattern....I don't necessarily agree with that. If you've got a complicated algorithm that you can split up into small, relatively dumb private methods but don't want you're callers to execute then it makes sense to you private methods (this would be a composed method). If however, each private method is also complicated, it may be useful to have unit tests implemented for each of those, so make them internal (and give the Unit Test assembly access).
If you find yourself writing code you don't understand purely so you can say you've followed TDD, then it's not worth doing. Get in the habit of writing useable, maintainable code first and then look at moving to TDD.
|
|
|
|
|
Hi Martin,
Thanks for your valuable comments. Actually my point was this : I love TDD, I WANT to use TDD, But in reality, I find it inapplicable other than algorithm projects. My Complains are against the TDD Framework that is available nowadays. I am glad that you also agreed that it is applicable to Algorithm based classes. But, Many Small project developers who are creating a Windows Application or Website by themselves, I dont know if they can practice TDD on those real world application where Algorithm part can be dominated by more UI related stuffs.
By the way, is it really not possible for microsoft to develop a TDD framwork which can test Private methods ? Maybe by using Reflections ? TDD could be very applicable if it allowed to test private methods.
Anyway, thanks for your insights. I highly appreciate for your time.
|
|
|
|
|
This really isn't the forum to post this question because it's more about your architecture and development process rather than C# itself. However, having said that, I'll attempt to answer some of your points.
The reason that you tend not to test private methods is because there should be no way to reach those methods other than through a public method; if somebody uses reflection to get to a method you intended to hide then really, it's their own lookout if things don't work the way they expect. The key point here, is that you test the public methods in such a way that you cover the private methods. If a private method cannot be reached, then you have code that cannot be executed - this is why code coverage is an important guideline in TDD.
TDD is not a be all/end all. If you write layered applications, TDD tends to be a reasonable fit; it's not perfect because you can fall into the trap of writing code to pass tests rather than writing code to satisfy a problem. As your development progresses, you find that you drop code that you wrote to simulate database access in favour of real database access (for instance). Where TDD really helps, is in asking you to think in terms of SOLID development - you can develop monolithic methods, but TDD tends to discourage this, and the idea that you can instantly tell if your code still runs when you change it. This, really helps once a project has gone live, as people move off the development into other areas - any changes can be instantly tested.
The important thing to remember is that TDD is not a magic bullet. Use it/don't use it. The important thing to rememember is that it's a tool available to you, and you should ignore it if it doesn't fit the problem.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: The important thing to rememember is that it's a tool available to you, and you should ignore it if it doesn't fit the problem.
---- This is a very good answer, Thank you very much for your time. I got some light from your reply.
|
|
|
|
|
You are welcome.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hi,
i want to host a control like numeric up-down control in datagrid cell..hw can i do that?
|
|
|
|
|
|
When drawing an item and setting its bounds, is there a way to use fractions? For instance if I want to start at X=1.4 and Y=2.5 and have Width = 10.5 Height = 11.5.
|
|
|
|
|
Too lazy to look it up he?
|
|
|
|
|
You remind me of the robot from Moon. You always have some sort of emoticon at the end of your posts.
|
|
|
|
|
You;re looking for RectangleF , then you can use floats eg.
X = 1.4f
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi there,
I've googled and searched the discussion groups to try to get a listing of companies that sell user security applications that I can bolt onto an existing application that I have built and I can't seem to find anything. Don't know if I'm searhing for the wrong terms or no one has built anything for this purpose.
Anyone know of products that allow you to bolt on things like a login, form/ field/table level security for a C# windows application?
Thanks
|
|
|
|
|
jaydel123 wrote: Anyone know of products that allow you to bolt on things like a login, form/ field/table level security for a C# windows application?
Aladdin[^] springs to mind, but there are more solutions. I'm curious about what gets recommended by others
I are Troll
|
|
|
|
|
Hi there, thanks for the reply except that alladin is for SaaS applications and not windows (winforms) applications. I want to be able to give the user the application and one of the forms is a user maintenance form that will add and remove users to the application I have built. In the backend it is either creating a windows authenticated user or a SQL authenticated user with an encypted password. Then you tell the security application what forms the user can access and it's very easy to make security application access calls to see what forms the users should be able to open.
I'm talking more about once the software is licensed on the users system how to control access to the application with users and groups.
Thanks
|
|
|
|
|