2013/03/29

Make Oracle Instant Client work

I installed Oracle Instant Client like others did, extract it at a folder, add the folder to path, change the folder's privilege, add some roles to that folder and have fully access... etc. None of them works.

So the ultimate way to make it work that I found is:
copy the following two files to your application folder "oci.dll" & "oraociei11.dll" and it will work. At least it works for me in my case.

PS: The "oraociei11.dll" has around 124MB of size, and this will make your application become a big monster. I hope you will never have to use this way.

2013/03/04

[C#] Dynamically load assembly (dll)

using System.Reflection;
using IterfaceLibrary;
 
IModuleInfo clientForm = null;
Form clientForm2 = null;
string formID = String.Empty;
Assembly newDll = Assembly.LoadFrom("Test.dll");
 
foreach (Type itemType in newDll.GetTypes())
{
  if (itemType.IsClass)
  {
    if (itemType.FullName.Contains("Form"))
    {
      // Assembly有implement Interface
      clientForm = Activator.CreateInstance(itemType) as IModuleInfo;
      MessageBox.Show(clientForm.ModuleName);
      clientForm.ShowForm(this, "From Main");

      // Assembly沒有implement Interface
      clientForm2 = Activator.CreateInstance(itemType) as Form;
      // 呼叫clientForm2裡面的ShowModuleID()方法,該方法回傳formID字串
      formID = itemType.InvokeMember("ShowModuleID", BindingFlags.InvokeMethod, null,
        clientForm2, null) as string;
      MessageBox.Show(formID);
    }
  }
}