Tuesday 29 March 2011

Could not load file or assembly CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304

If you get the error Could not load file or assembly CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304 when an application is deployed on to a server this could be caused before the incorrect crystal runtime could be installed on the server.

To begin with I downloaded the latest crystal reports 2008 runtime and installed on the server. This seemed to install version 12.0 assemblies. After a bit of searching on the net it seems that the version number of the assemblies changed to 13.0 in the Crystal reports for Visual Studio 2010 version. This means there is a seperate runtime to install if this is what the reports were built against.

The correct runtime can be downloaded from here:

SAP VS.net runtime distributions

Failed to open the connection. Database Vendor code 4060

I recently had a problem deploying crystal reports to a server after an upgrade to crystal reports for visual studio 2010. When running the report from the web application I was getting the error 'Failed to open the connection. Database Vendor code 4060'

It dawned on me that is may be due to an issue similar to the 'double hop' problem where ReportViewer looses its impersonation context. This was easy to resolve by changing the application pool identity to a user that has access to the datasources and databases. Sure enough everything started to play nicely after the application pool was changed to match the user the web application was impersonating.

If you are interested in the ReportViewer double hop problem then here is the link:

Report Viewer Impersonation Context

Friday 25 March 2011

BlackBerry MDS Simulator does not launch

Problem

The BlackBerry MDS Simulator appears to have started successfully; however, the command prompt window disappears after a few seconds.

Cause

The following are possible causes:

An incorrect version of the Java® software development kit (SDK) or Java Development Kit (JDK) is installed on the computer, or the SDK or JDK is missing.
The path environment variable is not set correctly.
The Java_Home environment variable is pointing to the incorrect Java version.
There is interference with existing environment variables.
Resolution

Complete the following:

Verify that a supported version of the SDK or JDK is installed as follows:
Review the Add/Remove Programs to determine the current version installed.
Search Windows® Explorer for the Java installation directory (e.g., C:\Program Files\Java\jdk1.5.0_21).
If there is no Java SDK or JDK installed, install one.

If an incorrect version of Java SDK or JDK is installed, remove it and install the version that is supported by BlackBerry JDE. See here for a list of supported versions of Java for the the BlackBerry JDE.When the installation is complete, make sure that the Java directory is created and that the environment variable has been set correctly.

When the installation is complete, make sure that the Java directory is created and that the environment variable has been set correctly.


Check the path environment variable:
Right-click My Computer and then select Properties. On the Advanced tab, click Environment Variables.
Verify that the C:\Program Files\Java\jdk1.5.0_21 directory appears first in the path environment variable, as in the following example:
C:\Program Files\Java\jdk1.5.0_21;C:\Perl\bin\;C:\Oracle\Ora81\bin;C:\Program Files\Oracle\jre\1.1.7\bin;%SystemRoot%\system32;%SystemRoot%


Note: If there are multiple versions of Java installed by other applications, move the Java SDK path to the beginning of the list.



Check the “JAVA_HOME” environment variable.
Right-click My Computer and select Properties. On the Advanced tab, click Environment Variables.
Verify that the Java_Home variable is pointing to the correct version of Java. The BlackBerry JDE software does not require the Java_Home variable to be set. It can be removed as long as there are no conflicts with other applications running on your local computer.
Edit the \INSTALL_DIRECTORY\MDS\setBMDSEnv.bat file and remove the reference to %cd%\ from the following line:

@set BMDS_CLASSPATH=%BMDS_CLASSPATH%;"%cd%\%1"


The line should now read as follows:


@set BMDS_CLASSPATH=%BMDS_CLASSPATH%;"%1"


Save this change and restart the BlackBerry MDS Simulator.

Monday 21 March 2011

How to open a window from a button in an update panel

If you have a control in an update panel and you dont want to add the whole control as a postback trigger ( if you are using a gridview and want one partiular row command to open a window for example ) then you can achieve this with the following code.

How to create a Unique index based on two columns

I had a requirement to have a constraint on a database table to not allow duplicate document no's in the table. This was complicated by the fact you could have the same document no in two different records in the table if the databaseID of the record was different. The constraint should also only be in place if there is a Value in the document No column.

Here is the SQL Query to add the constraint in SQL 2008.



If you are using SQL 2005 then you can achieve this by creating a view and adding a constraint to the view.

Friday 18 March 2011

How to Add Virtual PC hard disk to Virtual Box

If you want to get a VPC image mounted into Virtual Box without it blue screening on startup.

Here is how:
  1. Create a new Virtual Machine
  2. Set the details for the VM
  3. Set memory as normal
  4. Untick the Boot Hard disk Option
  5. Finish creating the machine
  6. Go into the Storage settings for the machine. Under the IDE Controller section click the add new Hard Disk Button
  7. Click choose existing disk
  8. Browse to the existing file
  9. You should now be good to Go. The reason it wont boot if you don’t add the disk as an IDE controller is because by default the disk is added as SATA and the virtual pc disks were not set up as SATA. If you selected the disk during the initial wizard then you will need to remove it from the SATA controller in the Storage settings and add it to the IDE controller

Thursday 17 March 2011

Error Reading File: Source Safe and Virtual PC

If you are using Source Safe in a virtual PC and it is behaving slowly and producing Error Reading from File messages then its likely you may have a duplicate MAC address if the virtual PC has been copied.

To resolve this make sure the virtual PC is closed and not in a saved state.

Edit the .vmc file to remove the MAC address. Find the following line:



Remove the number so the line appears as follows:


After you remove the number, Virtual PC will create a new MAC address the next time you start the virtual machine.

Thursday 10 March 2011

IIS Service Unavailable after setting 32bit (IIS 6.0)

I was having the "Service Unavailable" issue after I changed IIS to 32 bit mode. I found a solution that worked for me:

Our problem was that ASP.net was trying to run a 64 bit DLL, which failed after we reset IIS to 32 bit mode. All we needed to do was change the bitness of the ASP.net DLL to 32 bit mode. To do that, first turn on the server service. Once that service is running, run the following:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i -enable

This will reinstall ASP.NET with the appropriate bitness.

Configuring IIS to Run 32-bit Applications on 64-bit Windows (IIS 6.0)

To enable IIS 6.0 to run 32-bit applications on 64-bit Windows
  1. Open a command prompt and navigate to the %systemdrive%\Inetpub\AdminScripts directory.
  2. Type the following command:
    cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 “true”
  3. Press ENTER.

Monday 7 March 2011

JQuery Mobile: Switching Pages: new page does not get style

When clicking on any relatively linked page the new page is loaded and displayed but it does not contain any of the formatting love jquery mobile normally applies. When visiting any of these pages by themselves they all render properly but the same issue exists where you cant navigate between them.

The problem: In jQuery Mobile Alpha 2.0 all pages in the same root will not receive the proper style when linking to each other.

Example:
site/mobile/index.html <- contains a link to news.
site/mobile/news.html <- news will not receive style because index and news are in the same directory.

There are three solutions to fix this(for the time being before they release the next alpha).

Solution 1:
Use jquery 1.4.3 instead of 1.4.4. you lose icon in your headers but it's not a complete loss if you dont need them.

Solution 2:
place all your sub pages from your index in sub folders or in a sub folder. You cant use a flat site system but all the pages will style properly.
Example:
site/mobile/news/index.html

Solution 3:
add a "?" at the end of the hyperlink. This tells the jquery mobile that it needs to render a new page but it could be the same page so have it style properly. (if your hyperlinks already have GET variables in your URLs then you are all set.)
Example:
site/mobile/news.html?

Friday 4 March 2011

Command Prompt from here context menu item


Navigate in your Registry to
HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell
and create a key called "Command Prompt" without the quotes.

Set the default string to whatever text you want to appear in the right-click menu.
Create a new key within your newly created command prompt named "command," and set the default string to
cmd.exe /k pushd %1
You may need to add %SystemRoot%\system32\ before the cmd.exe if the executable can't be found.
The changes should take place immediately. Right click a folder and your new menu item should appear.

Thursday 3 March 2011

Fixing “ResGen.exe exited with code–1073741701” in Visual Studio 2010

Set the 32-bit flag on resgen.exe

Option 1:
  1. Open a Visual Studio command-prompt as an administrator
  2. Navigate to the Microsoft SDKs\Windows\v7.0A\bin directory.
  3. ***SAVE A COPY*** of your original resgen.exe file. This is very important if you want to be able to replace our tweak with the original file without having to repair your installation.
    copy resgen.exe regen.exe.old
  4. Set the 32-bit flag to true using corflags.exe
    corflags.exe resgen.exe /32BIT+ /Force
  5. Note the warning about strong name issues. On my machine the build now succeeds, without needing to do any additional work due to strong name issues. IF you have problems after trying this method, you can try the following to skip string name verification for that assembly-
  6. Register resgen.exe for strong name verification skipping using sn.exe
    sn.exe –Vr resgen.exe
    WARNING! This is a security risk. You are bypassing strongname verification for this assembly, making it possible for malicious code posing as resgen.exe to execute. To turn verification back on, use sn.exe –Vu resgen.exe

Option 2:
Add the following line to your csproj file ...













Option 3:
Try using the 64-bit version of tracker.exe, even for 32-bit builds, when targeting .NET 3.5 and lower. Indicate you want to run ResGen as a tool, and that it is ManagedIL (Managed32Bit doesn't work because of this flagging issue):

a. Add this to your MSBUILD command-line:


b. Or add this to your project:

System.InvalidOperationException: Request format is unrecognized

If you try browsing to a web service asmx file and get the error message

System.InvalidOperationException: Request format is unrecognized

This may be becuase the required protocol is disabled in the web config file.

Here is a list of the possible protocols that could be missing from the web or machine.config.

Tuesday 1 March 2011

Could not load file or assembly 'your assembly name' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I just had a problem with the error message in IIS that reads:

Could not load file or assembly 'yourassemblyname' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Sicon.API' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Now this message is not particularly helpful but after a while searching the problem was caused becuase the web application was installed on a 64bit server, in a 64bit application pool when the web application is compiled specifically for 32bit.

This is easy enough to fix by changing the application pool to allow 32bit applications from the advanced settings screen.