January 13, 2009

Changing version of .net framework dependency for setup and deployment project in visual studio 2008

Filed under: .net,vs.net Himanshu @ 3:50 pm

Its easy to do, but not obvious to locate, at least to me. It took a while for me to find, so I thought let’s log it, in case if I need it in future, or someone else might need it. I need to create setup that depends on .NET framework 2.0. instead of 3.5 which is default in VS.NET 2008.

After creating setup and deployment project, double click on dependency of .net framework in solution explorer:


Now, you should be able to see launch condition for .net framework in “Launch Conditions” tab. Until you double click for the first time, node do not appear in launch conditions. And that’s where I wasted some hours:

lauch condition

Select the node and see the property window, where you will find the answer of the question:


November 21, 2008

Navigate and injecting C# code using visual studio macro

Visual studio macros are great, probably I will write this in all posts that I write for macros :). Sometime back, I need to change a fairly big CF.NET application such a way that it will log a line on each function entry and on function exit. We were tracing for cause of intermittently occurring GWES.EXE error, and we were tracing it from multiple directions. The error code of GWES was 0xC0000005, which means someone was trying to access something, which was never allocated or is being accessed after releasing it. Application was multi-threaded, and hence it was difficult to understand which thread will do what at what time.

Moving back to original point, we wanted to log entry and exit of each functions. There can be more then one way to do that, but we have selected to change each functions. And to change each functions I have selected to use developer named “VS.NET macro”.

From macro it is possible to navigate through solution and projects. So macro first needs to find out all class types from a project, and then for each class, iterate through its member and find out functions that has body. If function has body, inject the code that logs line on function entry and exit.

It was easy to find function entry, but there can be many way function ends, like exception is being thrown, or based of some condition it may execute “return”, or body of the function is ended and hence return. To accommodate such cases, we decide to use “using statement” of C#.

All right, enough of the background, have look at Macro code here

March 17, 2008

VS.NET, macro creating string const, and macro creating string resource entry

Filed under: .net,programming,robo coding,vs.net Himanshu @ 2:08 pm

Per me, macro is one of the most important feature for any text editor or software IDE. And hence, it is very import for VS.NET user to understand and then use macros available in VS.NET. VS.NET macros are very powerfully tool and they help in lot more different ways.

I have created two macros that are very common in their need. While programming, we need to create string const on regular bases. It becomes inconvenient to go to top of the class while writing a method body for same class and create constant. Macro in library attached with this post becomes handy at that time.

Same use case hold very much true for creating string resources while writing method body. And it becomes really very easy if string resource can be created while writing method body.

For those who thinks like me (or want to 🙂 ), I have attached two macros with this post. Macro works for VS.NET 2005, haven't tested in any other version. But should work fine in VS.NET 2003 or VS.NET 2008

March 10, 2008

Automation, Software Engineering, Productivity

Filed under: programming,robo coding,vs.net Himanshu @ 12:22 pm

It’s good to use computer as far as it is possible to do. Around the world, many computer engineers work for others to generate code-base that instructs computers to act as it’s user would like it to. Computers gives more accessibility to the information, knowledge, gives more processing power, help to be more managed and allow us to utilize much more clock cycle of our main thread – a human main thread, which can really do the thinking. Ultimately that what the difference is between human and machines in today edge. That is why we have many software built today. Operating systems, financial applications, engineering application and many others, including the RAD (Rapid application development) tools. RAD in compare to the edge where programmers need to punch the cards makes developer very efficient in generating computer instructions. And of-course even computers are also much more efficient now a days.

Anyway, many of us knows most of above that I have written. The point here is use computers, as much as you can to increase productivity. And it applies to software engineers as well. To support that, I’m planning to take several efforts that will include blog-posts, posting some tools, VS.NET macros, snippets and something else that will help.

Although this wouldn’t be the only goal of this blog-post repository (making it explicit as this is first blog-post in this repository), I’m starting with posting first version of first macro that creates resource entry of a selected string in the code. The macro is posted separately to make both more manageable. I’m linking my first macro with this blog post here, but will not do same for other automation posts that I will post later. To find them you should see posts tagged under RoboCoding. Please mind that the macro is in version-1, I will fix and enhance it as time ticks and the need. As well as more of such will come in future.

Powered by WordPress