Gino Abraham's Blog

April 2011 Entries

Accessing Interop dlls makes winforms exes non responsive

In one of my windows application, I was making use of Domino inerop for accessing document data from lotus notes. Whenever the interop was probed for some bigger response, my application use to be non responsive or hang.Once the call to inerop is done the application was accessible. Users will not know the progress in such scenarios.

You can avoid this by introducing a Background thead. Move all the inerop method calls to a seperate function. On you event handler add a background thread and call the function.

Thread newThread = new Thread(FunctionWithInteropCalls);

newThread.IsBackground = true;


If the thread is marked as a Background thread, the thread will be killed automatically during Application.Exit()

Now if function which is executed by newThread should access windows objects created in the main thread, you will have to handle it. Sample below shown how you can achieve this.

public void AccessMainThreadObj(string value)
if (InvokeRequired
this.Invoke(newAction<string>(AccessMainThreadObj), value); 
    textbox1.Text = value.Substring(2);
   richTextBox2.Text += value;
void FunctionWithInteropCalls()
AccessMainThreadObj("#1 To update textbox1");
AccessMainThreadObj("To update richTextBox2");

 Create a method to update the value of the controls in the form. Basically this function checks whether the current process needs an invoke, if yes comes through the builtin invoke method.



Enums in C# - To get text value from corresponding number

Enums are always a favourite when we want to restrict users while sending some string to a generic methods. Was exploring how to get the text of the enum from the correspoing number. .Typecasting the number to the enum type would get the text from enum. Have shared a sample on this

Using System;

namespace ConsoleApplication1 {

class Program{

enum WeekDays { Sun = 1, Mon = 2, Tue, Wed, Thu, Fri, Sat }

staticvoid Main(string[] args) {





Output :



Updating Mutliselect CheckBox columns in sharepoint 2010 using SPClientCotext

In one of my project we had a scenario where we have to update a multi select choice column in sharepoint list from out client application. The way of comma seperated way was tried but didnt work for us. After lot of trial and error we found that the value should can updated as a string array.

oList["MultiChoiceColeName"] = new string{"FirstVal", "ThirdVal", "lastVal"};

Lotus Notes Interop to connect from dotnet application to Lotus Notes Database

While connecting to Lotus notes database from dotnet application using Interop.Domino dll, I was getting the following error.  (“Retrieving the COM class factory for component with CLSID {29131539-2EED-1069-BF5D-00DD011186B7} failed due to the following error: 80040154”)

When i installed Domino Server setup we the issue was solved. But unforunately this will not roll out as we might have to run the migration application in different machines. After searching a lot i net i found an article in IBM site about a dll named nlsxbe.dll.

Once I registered this dll using regsvr32, i was able to connect to lotus database with just lotus client installation and Interop.Domino object.

nlsxbe.dll will be found in lotus notes installed folder. 

More to come on lotus notes migration, watch this space.