Reference Sitefinity Dll's from External Site - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Reference Sitefinity Dll's from External Site

  • Reference Sitefinity Dll's from External Site
  • I am working on an external framework that acts as a communication layer between Sitefinity and another 3rd party system. The 3rd party system is the central authority for all of our client data, but I would like to be able to create/delete/update user accounts in Sitefinity based on changes that are made to the accounts in the 3rd party system. I know that Sitefinity supplies some web services for handling user accounts, but they don't appear to meet my needs.

    So now for the issue I'm running into. In my external framework, I am trying to create a UserManager object using the following code:

    var manager = UserManager.GetManager();

    However, the UserManager throws the following exception on this line. "The type initializer for 'Telerik.Sitefinity.Localization.Res' threw an exception." "Value cannot be null.\r\nParameter name: path1". I have referenced Telerik.Sitefinity, Telerik.Sitefinity.Model and Telerik.Sitefinity.Utilities. I'm wondering if I'm missing some configuration setting(s) for the membership and/or data providers. I did place the following in my app.config file, but it did not seem to help.

            <membership defaultProvider="Default">
                    <add name="Default" type="Telerik.Sitefinity.Security.Data.SitefinityMembershipProvider, Telerik.Sitefinity"/>

    Can anyone point me in the right direction? Thank you!
  • Dustin, this isn't something I've attempted, so the support team might have more insight than I, but here is my take.

    I'm guessing the main problem is that a lot of the sitefinity components rely on the configuration, which is no longer stored in web/app config, but rather in separate configuration files in app_data. I don't know if this is a hard-wired path, but this is where it usually initializes everything from.

    I was about to suggest that you use the web services, but you say it doesn't meet your needs. what exactly is missing? I'm sure the team would find that feedback valuable and perhaps they can provide you with a workaround.

    finally, would it be possible to instead develop this framework to work within the context of a Sitefinity website, and expose itself via your own web service or API? This way you would have the full sitefinity, context, and not have to try to reproduce it in an intermediary system.

    hopefull the support team can give you more insight, but until then I hope this is helpful!
  • SelAromDotNet, thank you for your response. I thought about the configuration files and moved all of them out to my external framework project with the same folder structure as my Sitefinity site. Sorry, I should have mentioned that in my original post.

    An example of what I need to do is query the Sitefinity database to pull back a single user based on a Guid that is held in a custom field in the users profile. I did not see any service method that would allow me to pull users based on custom fields. Feel free to correct me if I just overlooked this functionality.

    As far as creating the framework in the context of a Sitefinity site, that is probably not ideal. I simplified my explanation in my original post, but the framework is actually  going to tie a number of systems together so it would be nice to have all of the code live in the same location.

    Thank you again for your help. I really appreciate it.
  • Did you ever resolve this issue? I'm having the same problem.
  • Sorry Tim, I have not found a resolution to this issue yet.
  • Hello Dustin,

    Copying the Sitefinity and OpenAccess assemblies to your project's /bin folder as well as the configuration files to ~/App_Data/Sitefinity/Configuration should be enough for you to initialize a manager. I created a blank ASP.NET web application and copied the entire /bin folder of a Sitefinity application to the /bin folder of my test application as well as the entire ~/App_Data/Sitefinity folder and also added the following entry in the web.config <providers> collection

    <add name="Default" type="Telerik.Sitefinity.Security.Data.SitefinityMembershipProvider, Telerik.Sitefinity" />

    and was able to successfully execute the following code:

    var userManager = UserManager.GetManager();
    var users = userManager.GetUsers();

    Is your application a web application or some other type? Making Sitefinity API work using non-web application would be impossible as our API heavily relies on the ASP.NET web API like HttpContext, Request, Response, which are not present in, e.g. WinForms applications.

    Kind regards,
    Lubomir Velkov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  • I would like to do a similar thing using the api from another web project (external to Sitefinity).

    Is there a more detailed blog post/kb article/documentation anywhere on Lubomir Velkov's solution?  

     I followed the instructions above but I get an exception when I try to use a basic NewsManager.

    public List<NewsItem> GetAllLiveNewsItems()
                NewsManager newsMgr = NewsManager.GetManager();
               return newsMgr.GetNewsItems().Where(item => item.Status == ContentLifecycleStatus.Live).ToList();          

     I got the following exception.  It looks like it's a problem with the configuration but I copied everything from ~App_Data/Sitefinity into my new project.


    System.Reflection.TargetInvocationException was unhandled by user code
      Message=Exception has been thrown by the target of an invocation.
           at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
           at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
           at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
           at System.Activator.CreateInstance[T]()
           at Telerik.Sitefinity.Data.ManagerBase`1.GetManager[T](String providerName, String transactionName)
           at Telerik.Sitefinity.Data.ManagerBase`1.GetManager[T]()
           at Telerik.Sitefinity.Modules.News.NewsManager.GetManager()
           at EcoATMTest.Controllers.NewsController.GetAllLiveNewsItems() in c:\Users\Gary\Documents\BitBucket\EcoATMTest\EcoATMTest\Controllers\NewsController.cs:line 25
           at EcoATMTest.Controllers.NewsController.Index() in c:\Users\Gary\Documents\BitBucket\EcoATMTest\EcoATMTest\Controllers\NewsController.cs:line 20
           at lambda_method(Closure , ControllerBase , Object[] )
           at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
           at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
           at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
           at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
           at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
           at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
           at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
           at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
           at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
           at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
           at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41()
      InnerException: System.NullReferenceException
           Message=Object reference not set to an instance of an object.
                at Telerik.Sitefinity.Abstractions.ObjectFactory.GetArgsByName(String name, Type baseType)
                at Telerik.Sitefinity.Configuration.Config.VerifySectionRegistered(Type sectionType)
                at Telerik.Sitefinity.Configuration.Config.GetSectionInternal(Type sectionType, Boolean safeMode)
                at Telerik.Sitefinity.Configuration.Config.GetSectionPrivate(Type sectionType, Boolean safeMode)
                at Telerik.Sitefinity.Configuration.Config.GetSectionPrivate[TSection](Boolean safeMode)
                at Telerik.Sitefinity.Configuration.Config.Get[TSection](Boolean safeMode)
                at Telerik.Sitefinity.Configuration.Config.Get[TSection]()
                at Telerik.Sitefinity.Modules.News.NewsManager.get_ProvidersSettings()
                at Telerik.Sitefinity.Data.ManagerBase`1.GetProvidersSettings()
                at Telerik.Sitefinity.Data.ManagerBase`1.Initialize()
                at Telerik.Sitefinity.Data.ManagerBase`1..ctor(String providerName, String transactionName)
                at Telerik.Sitefinity.Data.ManagerBase`1..ctor(String providerName)
                at Telerik.Sitefinity.Modules.GenericContent.ContentManagerBase`1..ctor(String providerName)
                at Telerik.Sitefinity.Modules.News.NewsManager..ctor(String providerName)
                at Telerik.Sitefinity.Modules.News.NewsManager..ctor()


  • In addition to Lubomir's post I also had to add the following to my configuration in order to get a create a Manager.


    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
    <remove name="FormsAuthenticationModule" />
    <remove name="ScriptModule" />
    <remove name="Session" />
    <add name="ScriptModule"
    type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add name="Session"
    preCondition="" />
    <add name="ClaimsPrincipalHttpModule" type="Microsoft.IdentityModel.Web.ClaimsPrincipalHttpModule, Microsoft.IdentityModel, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <add name="SitefinityClaimsAuthenticationModule" type="Telerik.Sitefinity.Security.Claims.SitefinityClaimsAuthenticationModule, Telerik.Sitefinity" />
    <add name="Sitefinity" type="Telerik.Sitefinity.Web.SitefinityHttpModule, Telerik.Sitefinity" />
    <add name="SessionAuthenticationModule" type="Telerik.Sitefinity.Security.Claims.SitefinitySessionAuthenticationModule, Telerik.Sitefinity" />
    <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" />
    <add name="SitefinityAnalyticsModule" type="Telerik.Sitefinity.Analytics.Server.DependencyResolution.Module.DependencyRegistrarHttpModule, Telerik.Sitefinity.Analytics.Server.Infrastructure" />



  • I'm trying to the same.  Add a user from windows app (.Net custom app - that manages ALL our user)

    So your saying this can't be done?   I get the null error on UserManager.GetManager();

    I find the webservices  do not meet my requirements.

    Any way to pass in the DataConfig or any other info?



  • I'd like to vote for a non-web interface route too, if you're considering any future upgrade in this area. I bumped into the same issue that Dusting mentioned at the start of this thread.