mardi 8 janvier 2019

Using Reflection EWS API C#

I'am trying to using EWS API in SSIS Script Task, but, the server doens't have the correspond dll: Microsoft.Exchange.WebServices.dll

So, the reflection is the only solution i found, the file of dll it's in the server and i can use.

I need to instantiate a subclass of an abstract class, but the compiler give this message error: Not found the constructor of Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo

I tried to use Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo, Microsoft.Exchange.WebServices.Data.SearchFilter.IsEqualTo and get nested type of SearchFilter, and none works

   Type typeSearchFilter = DLL2.GetType("Microsoft.Exchange.WebServices.Data.SearchFilter");


    var typeSearchFilterIsEqualTo = typeSearchFilter.GetNestedType("IsEqualTo");

    Type typeSearchFilterIsEqualTo0 = DLL2.GetType("Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo");

    Type typeSearchFilterIsEqualTo1 = DLL2.GetType("Microsoft.Exchange.WebServices.Data.SearchFilter.IsEqualTo");

    dynamic searcherFilter = Activator.CreateInstance(typeSearchFilterIsEqualTo, new object[] { folderSchemaDisplayName, folder})

I expected create a new instance of SearchFilter.IsEqualTo and pass the parameters to constructor and save the result in variable, like this

          dynamic searcherFilter = Activator.CreateInstance(typeSearchFilterIsEqualTo, new object[] { folderSchemaDisplayName, folder});

            var filter = searcherFilter;





Aucun commentaire:

Enregistrer un commentaire