I am writing a c# winforms application where I want to be able to call the EC open dialog box and save dialog box and pass a particular path and filename to it and to then open/save a document.
I have a reference to ECSDK64.dll (C:\program files (x86)\OpenText\Enterprise Connect\ECSDK64.dll) and have imported the EnterpriseConnectSDK namespace.
Using the Dev Guide examples I have the following code:
OpenDialog Code:
private void OpenLiveLink()
{
object o = null;
object Plugin = null;
EnterpriseConnectSDK.IEnterpriseConnectSDK oSDK = null;
oSDK = o as EnterpriseConnectSDK.IEnterpriseConnectSDK;
EnterpriseConnectSDK.ICallContext context = oSDK.CreateContext();
Plugin = oSDK.GetPlugin(context,"plugID");
if (Plugin == null)
{
MessageBox.Show("Plugin object Creation failed. Exiting script");
return;
}
string ECItemID="";
try
{
}
catch
{
}
finally
{
}
}
SaveDialog Code
private void SaveLiveLink(string iFilePath, string iFileName)
{
object o = null;
EnterpriseConnectSDK.IEnterpriseConnectSDK oSDK = null;
EnterpriseConnectSDK.IPlugin plugin = null;
EnterpriseConnectSDK.ICallContext context = null;
oSDK = o as EnterpriseConnectSDK.IEnterpriseConnectSDK;
context = oSDK.CreateContext();
context.ParentWindow = 0;
plugin = oSDK.GetPlugin(context, "pluginID");
string FilePath = iFilePath;
string initialFileName = iFileName;
string[] ar = new string[]
{
"Word Document (*.docx)||.docx",
"Word Macro-Enabled Document (*.docm)||.docm",
"Word 97-2003 Document (*.doc)||.doc",
"Word Template (*.dotx)||.dotx"
};
EnterpriseConnectSDK.ISaveContext SaveInfo = null;
SaveInfo = oSDK.SaveDialog(context, ar, initialFileName);
if (SaveInfo == null)
{
MessageBox.Show("Save Info object is null. Exiting script.", "");
}
else
{
}
}
Both sets of code fail on the following line
EnterpriseConnectSDK.ICallContext context = oSDK.CreateContext();
with the error:
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=IPSLivelink
StackTrace:
at IPSLivelink.Form1.OpenLiveLink() in d:\UK950153\Documents\Visual Studio 2013\Projects\IPSLivelink\IPSLivelink\Form1.cs:line 153
at IPSLivelink.Form1.cmdOpenLL_Click(Object sender, EventArgs e) in d:\UK950153\Documents\Visual Studio 2013\Projects\IPSLivelink\IPSLivelink\Form1.cs:line 183
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.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at IPSLivelink.Program.Main() in d:\UK950153\Documents\Visual Studio 2013\Projects\IPSLivelink\IPSLivelink\Program.cs:line 18
InnerException:
I can't see what I have done wrong here. Any advise is welcomed.
Tony D