Monday, June 27, 2011

Debugger doesn't stop at breakpoints in VS 2005

Problem:


Debugger in VS 2005 does not stop at breakpoints.


Solution:


Make sure you have the debug setting in the web.config (http://forums.asp.net/p/1278210/2440003.aspx#2440003)
Ok, I already had the corrects settings, yet still the same problem.
This resolved it:
right-click solution --> configuration. My settings where: configuration:.Net, I changed it to Active .Net.




Learning is doing ...
Robert

Wednesday, October 6, 2010

How to change compile dir in studio


Problem:

When you do a build of a web site in VS, it puts the generated dll's in the \WINDOWS\Microsoft.NET\Framework\[your .net version]\Temporary ASP.NET Files directory. When it's time to deploy you have to search for the generated dll's, annoying.

Wouldn't it be handy to have VS put the dll's where you want them?

Solution:

Create the following section in your web.config:
<compilation debug="true" tempDirectory="c:\yourdir">

Learning is doing ...
Robert

Thursday, May 15, 2008

Project does not have a valid Sub Main

I encountered this error and it didn't make sense to me because I didn't have a Sub Main. Why vb.net gave that message is still a riddle to me. How did I resolve this? First you need to find out to what project the error pertains. Unfortunately double clicking the error does not tell you where the error resides. So select the messages tab and you will find in what project this error occurs.


Once you know what project this occurs, copy the code and paste it temporarily in a text document. Then remove that particular project. Then save all and close the solution. Then look up the physical location of the project that you just deleted and make sure that the directory of the deleted directory does not exist. Now restart your solution and add back your project again. And voila, no more errors.

Monday, May 12, 2008

Stack Frame

When you use many functions and procedures it can be handy to know where run time error occur.
The class StackFrame allows you to query the calling function.

Example:

Private Function SomeFunction() as Boolean

Try
_balance = -100
Catch ex as Exeption
Throw new Exception("Balance cannot be negative. Function: " & ((New StackFrame).GetMethod.Name), ex)
End Try
End Function


Monday, May 5, 2008

Add array to arraylist

I'd like to elaborate a bit more on arraylists. What if you utilize a class that returns an array. Maybe you made a call to a database and it returns you an array. But you want to use the nice stuff..eh. like in the arraylist..!

Well, we can still use the arraylist. In order to use the arraylist we have to add our array to an arraylist. We will use the addRange method. Here is how:

We will use our good old cars array.

dim cars(2) as string
dim listcars as new ArrayList

cars(0) = "ford"
cars(1)= "chevy"

listcars.AddRange(cars)

There you go, we added our cars array to our arrayList listcars. So now we are able to use all the nice methods that listcars exposes.

I don't know yet why Microsoft added the array and arraylist, why not use the arraylist?

happy programming

ArrayList vs Array

While I was working with arrays I, in particular the array, I noticed something annoying. The annoying thing is that the array class in vb.net does not expose a delete or remove method. So, in order to remove an element you would have to use a For..Next loop to find the item, set it to Nothing and resize the array. vb.net being a powerful programming language should have a better and shorter way to do this. Well guess what?... There is!.
What would we use then?:

ArrayList


ArrayList exposes the remove method and will resize the array for you after you remove an item.

How does that work ?

Let's use our cars array again, but now, make it an arraylist.

(you need to use new so the cars will be an object of arraylist)
Dim cars As New ArrayList(3)

Now let's add some cars:

cars.Add("ford")
cars.Add("chevy")

cars.Add("dodge")

We don't even have to tell the index, now isn't that handy?!

Ok, now we want to remove the "chevy" from our cars arraylist.

We simply do this:

cars.Remove("chevy")

You can check the length of the cars arraylist using the count property. (cars.count) and you will see that it now contains 2 elements.

Hope you learned something new ;o)