3

I have a Tridion 2013 Event System extension DLL that references a few other DLLs. The referenced DLLs are present in the C:\Program Files (x86)\Tridion\bin folder and is doing its job fine when relevant events are fired either in the CME or via the Core Service.

However, if the Core Service is recycled or restarted, on the 1st request to the Core Service (and only on the 1st request; subsequent requests are fine). I get the following exception:

Initialization of the extension '<path to extension>' failed.
Could not load file or assembly '<qualified assembly reference>' or one of its 
dependencies. The system cannot find the file specified.

Component: Tridion.ContentManager.CoreService
Errorcode: 0
User: NT AUTHORITY\NETWORK SERVICE

StackTrace Information Details:
   at Client.Tridion.Events.GuidelinesHandler..ctor()
   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(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Tridion.ContentManager.Extensibility.TcmExtension.LoadExtensions()
   at Tridion.ContentManager.Extensibility.TcmExtension.LoadExtensions()
   at Tridion.ContentManager.Extensibility.TcmExtension.InitializeExtensions()
   at Tridion.ContentManager.Session..ctor(IEnumerable claimSets)
   at Tridion.ContentManager.CoreService.CoreServiceBase.get_CurrentSession()
   at Tridion.ContentManager.CoreService.CoreServiceBase.GetList(String id, 
       SubjectRelatedListFilterData filter)
   at SyncInvokeGetList(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, 
       Object[] inputs, Object[]& outputs)
   at Tridion.ContentManager.CoreService.CoreServiceInvoker.Invoke(Object instance, 
       Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(
       MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(
       MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(
       MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(
       Boolean isOperationContextSet)

I don't want to have to GAC install the referenced DLLs as its obviously working after the first request.

Its like the first startup has a different working directory, and then starts looking in the right place for subsequent requests.

Any help diagnosing or resolving this issue would be much appreciated.

UPDATE

This is the Core Service client creation code:

public static ICoreService Create(string host, string user, string password)
{
    var binding = new BasicHttpBinding
    {
        MaxBufferSize = 4194304,
        MaxBufferPoolSize = 4194304,
        MaxReceivedMessageSize = 4194304,
        ReaderQuotas = new XmlDictionaryReaderQuotas
        {
            MaxStringContentLength = 4194304,
            MaxArrayLength = 4194304
        },
        Security = new BasicHttpSecurity
        {
            Mode = BasicHttpSecurityMode.TransportCredentialOnly,
            Transport = new HttpTransportSecurity
            {
                ClientCredentialType = HttpClientCredentialType.Windows
            }
        }
    };

    var endpoint = 
        new EndpointAddress(host + "webservices/CoreService2012.svc/basicHttp");
    var factory = new ChannelFactory<ICoreService>(binding, endpoint);

    if (factory.Credentials != null)
    {
        factory.Credentials.Windows.ClientCredential = 
            new NetworkCredential(user, passsword);
    }

    return factory.CreateChannel();
}

UPDATE 2 This is the GuidelinesHandler's constructor, however, I'm pretty sure the code inside here isn't throwing the exception... Activator.CreateInstance will attempt to invoke the ctor and part of this process is attempting to resolve any required DLLs.

I'm going to try enabling fusion logging on the server and see if I can get any more information on where its looking for the DLLs.

public GuidelinesHandler()
{
    try
    {
        SolrNet.Startup.Init<GuidelinesResult>(_solrUrl);
    }
    catch (Exception ex)
    {
        Log("Error initializing SolrNet: {0}".FormatWith(ex), TraceEventType.Error);
    }

    EventSystem.SubscribeAsync<Component, CheckInEventArgs>(CheckIn, 
        EventPhases.TransactionCommitted);
    EventSystem.SubscribeAsync<Component, DeleteEventArgs>(Delete, 
        EventPhases.TransactionCommitted);
}
  • Is it the same case if you recycle you DCOM+ and invoke your event from the CME? If not, then it must be the code and specifically the constructor of your Core Service client code which may some issue. Is it possible for your to share the Constructor code of the Core Service client – Pankaj Gaur Sep 25 '13 at 11:25
  • Are you sure that no other versions of your referenced DLLs are available somewhere else on the system or perhaps even in the GAC already? – Bart Koopman Sep 25 '13 at 11:36
  • @BartKoopman yes, this is the only copy of the DLLs present, definitely not in the GAC. – James Simm Sep 25 '13 at 12:36
  • Not specifically to this error, but on the "GAC vs local issue", some people have used ILMerge to work around that. See stackoverflow.com/questions/10348103/… or tridion.stackexchange.com/questions/1700/… or simply google.com/search?q=tridion+ilmerge – Frank van Puffelen Sep 25 '13 at 20:15
  • From the call stack looks like it is failing to instantiate Client.Tridion.Events.GuidelinesHandler constructor. Could you share the empty constructor from that class. – Likhan Sep 26 '13 at 5:49
5

So... after enabling Fusion logging, I've tracked down the source of this error.

It appears that the Core Service uses C:\Program Files (x86)\Tridion\webservices\bin as its bin directory, not C:\Program Files (x86)\Tridion\bin, so it fails to locate the referenced DLL.

*** Assembly Binder Log Entry  (26/09/2013 @ 09:24:27) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = Client.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Tridion/webservices/
LOG: Initial PrivatePath = C:\Program Files (x86)\Tridion\webservices\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\webservices\63130608
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\webservices\63130608
LOG: AppName = 20ed6b29
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\Tridion\webservices\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/webservices/63130608/20ed6b29/Client.Common.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/webservices/63130608/20ed6b29/Client.Common/Client.Common.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Tridion/webservices/bin/Client.Common.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Tridion/webservices/bin/Client.Common/Client.Common.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/webservices/63130608/20ed6b29/Client.Common.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/webservices/63130608/20ed6b29/Client.Common/Client.Common.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Tridion/webservices/bin/Client.Common.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Tridion/webservices/bin/Client.Common/Client.Common.EXE.
LOG: All probing URLs attempted and failed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.