Archive for category .Net

Could not load file or assembly ‘CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304’ or one of its dependencies. The system cannot find the file specified.

I have developed a windows application which generates report using basic Crystal Reports in Visual Studio 2008. It was working fine in my development environment but on the client machine it was throwing this error message when I try to access the report.

When I click the details of the error message, I have got the following:

System.IO.FileNotFoundException: Could not load file or assembly 'CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
File name: 'CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'
at DevInventory.InventoryReport.buttonPrint_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]

After spending few hours I realized the Crystal Reports run time need to be installed to access the report on the client machine. You can find the instruction in the support website.

According to the environment (Visual Studio, 64 or 32 bits) , you can download the .msi packages from the SAP website OR you can find the package in your local drive (ie: C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5).

Then install this into the client machine, that ‘s all!

Happy Reporting..! 🙂




, ,


How to determine XPath of a User Control in InfoPath 2007

When I was doing customization in InfoPath, I had some difficulties to find the XPath of user controls, after spending several minutes I found a way to determine the XPath in InfoPath 2007. I just wanted to share this in my blog, because there is no any straight forward answer in the web.

Step 1: Create a blank InfoPath template and add an User Control from the Controls Design Tasks (On your right hand side of the InfoPath). In this example I have added two Text Boxes and a Button and re-named them.

Step 2: Select the user control and click the Data Source in the Design Tasks.

Step 3: Now, you can see the selected control’s highlighted name in the Drop Down List.

Step 4: Click the Drop Down arrow and select the Copy XPath in the list.

Step 5: That’s all, you can use the XPath in your code. 🙂

Thanks, R./

1 Comment

How to set the default programming language for InfoPath 2007/2010

Recently I have developed a DIP (Document Information Panel) for a SharePoint template using InfoPath, which is accessing the data from a SQL database. So I got a chance to play around with InfoPath and faced some issues with the trust level security and all, I will post the step by step details later. 🙂

Depend on our requirements we can choose the programming language in InfoPath, there are 4 different languages (According to my knowledge C#, VB.Net, JScript and VBScript) in InfoPath and there are some limitation/difficulties in scripting languages (debugging, not supported in browser forms and lack of resources), so we will stick with our familiar C# or VB.Net. We can use either Visual Studio Tools for Applications (VSTA) or Visual Studio, in this example I used VSTA.

Step 1: Open a InfoPath template which you want to set the programming language.

Step 2: For 2007: Go to Tools menu and select Form Options (Tools –> Form Options)

For 2010:  Go to Developer tab menu and select Language button  (Developer Menu –> Language)

Step 3: On the Form Options dialog box, select the programming on the list, then select the language in the Form template code language drop down list box and click Ok (Programming –> Form template code language)

For 2007:

For 2010:

Step 4: We are ready to rock 🙂  If you want to code in the Form loading event, just go to Tools –> Programming –> Loading Events..



Step 5: Happy Coding..!




Leave a comment

How to get the current user’s OU (Organizational Unit) from AD (Active Directory) – C#

There are so many ways to get the user details form AD (Active directory), but I wanted to get the current user’s OU (Organizational Unit) from Active directory. There is no any direct method to get the OU (Actually I could not find anything on the web, if anyone get an easy way to find-out please let me know). I am currently developing a Custom Search for SharePoint 2007 and according to the OU, I want to display the search results.

Here is the method I have created and most of the comments I have put in the code itself. I used and C#.

public string GetOU(string username)
 string result = string.Empty;
 using (HostingEnvironment.Impersonate())
 //Getting the domain
 PrincipalContext yourDomain = new PrincipalContext(ContextType.Domain);

//Finding the user
 UserPrincipal user = UserPrincipal.FindByIdentity(yourDomain, username);

//If the user found
 if (user != null)
 // Getting the DirectoryEntry
 DirectoryEntry directoryEntry = (user.GetUnderlyingObject() as DirectoryEntry);
 //if the directoryEntry is not null
 if (directoryEntry != null)
 //Getting the directoryEntry's path and spliting with the "," character
 string[] directoryEntryPath = directoryEntry.Path.Split(',');
 //Getting the each items of the array and spliting again with the "=" character
 foreach (var splitedPath in directoryEntryPath)
 string[] eleiments = splitedPath.Split('=');
 //If the 1st element of the array is "OU" string then get the 2dn element
 if (eleiments[0].Trim() == "OU")
 result = username + "-" + eleiments[1].Trim();
 return result;

Please don’t forget to add the following references:

using System.Collections;
using System.DirectoryServices.AccountManagement;
using System.DirectoryServices;
using System.Security.Principal;

If you want to get the current user’s OU then you can call this method in the Page_Load event.

protected void Page_Load(object sender, EventArgs e)
string userName = Context.User.Identity.Name;
LabelOU.Text = GetOU(userName);

You will get the output like this:

I hope this small C# code will be helping someone! Thanks R./




, , , , , , , , , , , ,