Tuesday 22 October 2013

Handlers error while accessing sharepoint 2010 dll's in asp.net using C#

This is not an common issue related to handlers. We feel everything is fine and should work as expected.

The main issue with this is within IIS. To access dll's related to Sharepoint 2010 particularly termstore data, we need to change the website to classic mode not integrated mode. This will solve the handlers issue.

Tuesday 6 August 2013

Consume C++ COM EXE in C# and Invoke methods


The following steps will accomplish the requirement to consume old C++ COM component to consume in C# applications.
Step 1: First create a .net reference dll from the com exe file.
Open visual studio command prompt and run the following command to generate the dll.
tlbimp "c:\Path\xxx.tlb" /out:"c:\Path\xxx.dll"

Once the dll is generated, then add reference that dll to your C# project.

Step 2:
After referencing to invoke any method from the com exe, the following steps can be helpful.
//Get the GUID of com class
Guid clsid = new Guid("Com class GUID");
//Get the type of the com component
Type type = Type.GetTypeFromCLSID(clsid, true);
//Instantiate a new object
object instance = Activator.CreateInstance(type);
//Method name to invoke
string methodName = "MymehodName";
//execute method
type.InvokeMember(methodName, BindingFlags.InvokeMethod, null, instance, strArguments);


That's it :).