Saturday, October 17, 2009

bobj is undefined

When we use crystal report on asp.net application then some times we get this error. May be this error you can face on client server.

Checks

1. Check whether crystal report runtime is installed on you server

2. On IIS, Unser default website you can find crystalreportViewer12 virtual directory and in wwwroot\aspnet_client\system_web\20….\you can find this folder

3. If you are configuring your report web apps on other website then copy this aspnet_client folder to that directory and create same virtual direcotry.

for more details you can check following URLS
http://bytes.com/topic/net/answers/823323-crystal-report-error-bobj-undefined
http://www.codeproject.com/Messages/2463043/Re-Crystal-Reports-Error-BOBJ-is-undefined.aspx
https://forums.sdn.sap.com/message.jspa?messageID=7304519
http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6552&PID=20067

How to convert Bit to Byte array using calulations

You can convert the bit to byte array using C# built in function

BitArray ba = new BitArray(8);
ba[3] = true;
byte[] bar = new byte[ba.Length / 8];
ba.CopyTo(bar, 0); // bit array to byte array

Or

public byte[] getBitToByteArray(BitArray ScratchPadBitArray)
{
int byteArrayLength=ScratchPadBitArray.Length / 8;
byte[] ScratchPadByteArray = new byte[byteArrayLength];
for (int row = 0; row < byteArrayLength; row++)
{
ScratchPadByteArray[row] = 0;
for (int column = 0; column < 8; column++)
{
ScratchPadByteArray[row] += (byte)(Math.Pow(2, 7 – column) * Convert.ToInt32(ScratchPadBitArray[column + (row * 8)]));

}
}
return ScratchPadByteArray;
}

public byte[] getBitToByteArray()
{
BitArray ScratchPadBitArray = this.pixelBitArray;
int byteArrayLength = ScratchPadBitArray.Length / 8;
byte[] ScratchPadByteArray = new byte[byteArrayLength];
for (int row = 0; row < byteArrayLength; row++)
{
ScratchPadByteArray[row] = 0;
for (int column = 0; column < 8; column++)
{
ScratchPadByteArray[row] += (byte)(Math.Pow(2, 7 – column) * Convert.ToInt32(ScratchPadBitArray[column + (row * 8)]));

}
}
return ScratchPadByteArray;
}