Archive for category .Net

Crystal Reports for Visual Studio 2010

Note that the latest Crystal reports version is no longer in beta, this is a good video to help you get past the bumps of installing and getting it to work for the first time in .Net 2010:

You can ignore the instructions on how to get the download from their site as a couple of the steps are wrong (their site has changed since the video was made).
As of March 2012 get Crystal Reports for Visual Studio 2010 Download here
As of (June 22, 2011) it was available here (Still a useful page, especially if the new link goes dead. You know it will) Crystal Reports for Visual Studio 2010 Download here.

These are the same links:
Download Crystal Reports for Visual Studio 2010
Complete Package (EXE)
Click Once
Merge Modules
Redist Installation (32 bit)
Redist Installation (64 bit)

Well it seems the good people at Crystal have been dragging their feet a bit in releasing a new version for Visual Studio 2010.  I recently downloaded the beta version of Crystal for Visual Studio 2010, if you’re interested you can get it here:

I installed it on my machine and was having some good success, that is until I tried to run it the first time.  It seems there is a bug in it that requires this attribute be added to your app.config / web.config file:
<startup useLegacyV2RuntimeActivationPolicy=”true”>

Which has something to do with a change Microsoft made in .Net ver 4.0 that Crystal failed to handle before their release.

So after that one little hiccup I completed development of my project and all was well, which I thought wasn’t too bad for a beta version of software, that is, until I tried to deploy my change.

It seems the Crystal runtime has bloated a bit, it’s now 1gig+ and takes forever to install (over an hour on my clients’ machine).  Finally I had it and my app installed I then went to run my new app annnnddd.. crash.  Dang it.  It turns out that the beta version of the Crystal install does not support being installed on a machine that already has a previous version of Crystal on it, no matter what version.

So I tried uninstalling versions, re-installing versions, uninstalling versions on my machine, re-installing only the 2010 version and re-building.  No matter what I tried I could not get my report to run on my clients machine.

At this point I have no idea what the issue was, whether I was deploying it wrong, if the runtime installer for Crystal is broken, or if it’s something else entirely, but at this point if you’re interested in trying out Microsoft.Reporting.WinForms.ReportViewer I highly recommend it!

Ultimately I wound up using Microsoft’s Reporting engine, which I have to say was a delight to work with.  It has its own little oddities, but the first time I ran it, the FIRST time, it worked like a charm.

Thanks MS, sorry Crystal, you just lost a customer.


Leave a comment

Windows code samples – shell integration

There’s a interesting site out there with a number of windows example code samples.  They are ‘shell integration’ examples, it looks interesting.

Leave a comment

How to set the timeout for a webservice call .Net

There are a number of things that can time out in a webservice so this question has a few parts to it.  Among the things that can time out the main ones are:

1) The client making the call (your web app for example)
2) The webservice itself (by default a web method has a max run time set by the web.config / IIS)
3) Generally timeouts are related to database calls that take too long.  Your data call can time out getting data from the database.

Now generally you shouldn’t be extending timeouts if your app is taking too long to run.  If your app is timing out chances are your app is doing something wrong and is simply too slow.  Perhaps you should put the long running process on another thread?  Or improve your SQL?  Or maybe it actually is a hardware / network bottle neck.  The best reason I can think of for wanted to extend the timeout on a web-service is when you are in debug mode and having the service timeout during debugging is annoying and time wasting.

In any case, if you do genuinely need to extend the timeout for a web service add this to your web.config:
<httpRuntime executionTimeout=”600″ />
This node is a child of <system.web />


Leave a comment

Datatypes for .Net, Oracle, etc

Here’s a topic that’s integral to programming, but I doubt there’s a developer out there that has them all memorized, datatypes.  Different languages / data storage applications have different datatypes.  Often they’re not even compatible with each other so marshaling data from database to user interface and back again can be a challenge.

I’m going to keep a list of links to datatype definitions here, if you have one you would like me to add be sure to leave a message!

Visual Studio .Net 2003’s datatypes:

Visual Studio .Net 2010’s datatypes:

Oracle Datatypes:


Leave a comment

Datagrids – how to filter / sort

Datagrids – how to filter / sort
This topic has been done over and over and over again.  The thing is, it always seems like I’m trying to make the datagrid do something I’ve never done before on every project I write.

Here’s a good link on some basic filtering / sorting using datagrids:


Leave a comment

How to get the currently logged on user id in .Net / Web app

There are a few steps to getting the currently logged on user in a web app. First there is the code, which is quite simple. This is it:

Dim userName As String = My.User.Name
String userName = this.User.Identity.Name

There is some detail on this page as to how to parse out just the name from the domain:, though you really shouldn’t do this. In a properly constructed organization if there are multiple domains, say domain1 and domain2 then these users:
are not the same person. So using just the name without the domain is invalid logic.

Now that you have the code to get the current user you may find that it always returns an empty string, “”. If this is occurring it means that your website is not properly passing integrated windows authentication information to your app. This won’t happen in a fat client application but is likely to happen in a web app.

To enable authentication in your development environment change the authentication mode to “Windows” in your web.config like so:

<authentication mode=”Windows”>

This node is a child of <system.web> in vs2010.

Deploying this app to IIS should result in Windows authentication, as per the app.config file, if not the steps to configure a Virtual Directory are:
Open IIS admin-> Find your Virtual Directory->r-click on it->Properties->Directory Security->Under the heading “Anonymous access and authentication control” click Edit->Uncheck “Anonymous access”, check “Integrated Windows authentication”.

That’s it, happy integrated auth!

It turns out there are a number of headaches involved in getting integrated auth to work when calling from a windows form app to a webservice.  For the life of me I couldn’t get a VS2010 app to call a website hosted on an older version of IIS.  I imagine this is an issue with IIS being out of date, but seriously.  Integrated Auth has been around for ages, there HAS to be a way.

Anyway, I digress.  It turns out not everything implements IPrincipal so you can’t always use this.User to get the user.  If that doesn’t work there are these options as well:

If you know how to get VS2010 to call a webservice hosted on IIS 4 using integrated authentication be sure to let me know.


Leave a comment

How to specify what version of the Oracle client to use in .Net

I’ve been having quite the time recently getting old code, old Oracle databases and old Oracle database drivers to work alongside new code, new databases and new database drivers.  Some of the issues I’ve had are:

1) Microsoft wrote a oracle driver for .Net which they have now deprecated
2) Oracle doesn’t seem willing to allow downloads of version 9.x from their website, if you can figure out where to download it from, let me know.
3) .Net 2010 needs a recent version of the Oracle driver (around ver to replace the now deprecated Microsoft one.  Unfortunately when installed the new driver won’t connect to old databases.  Most of the databases I use are recent, but there is one I can’t connect to with 11.x
4) Oracle used to use a Oracle_Base folder to tell a machine what the default version of Oracle on it was.  They seem to be moving away from this approach but the old base dir still haunts.  My old VB6 apps for example are stuck in their ways and won’t use anything but the base version.

There’s more, but I’ll leave it at that for now.  Finally I found some details on how I can make this nightmare a little less frightening.  Firstly make Oracle 9.x the “Base” version, then in your .Net apps you can specify what version to use.  To do this modify your web or app config files, add this XML just before the closing </configuration> tag:

<add name="DllPath"               value="C:\ORACLE\Base\product\\client\bin"/>
<add name="FetchSize"             value="65536"/>
<add name="PromotableTransaction" value="promotable"/>
<add name="StatementCacheSize"    value="10"/>
<add name="TraceFileName"         value="C:\ORACLE\Base\product\\client\odpnet2.trc"/>
<add name="TraceLevel"            value="63"/>
<add name="TraceOption"           value="1"/>

Note: the paths have to be valid for your machine.

To make this process even easier, instead of modifying your web or app config you can modify your machine config.  This will affect all .Net apps written for a given .Net version.  EG modify this file:
With the same method mentioned above.  Now all 4.0 .Net apps will use that Oracle version by default.  They can still override that by putting a different one in their app or web config.

More info on managing Oracle installations can be found here:


Leave a comment