0

We are converting VBScript templates to .net compound templates and are facing some issues while using Broker Query Mechanism.

Our Old code looks like:

sQuery = "query" & nNumber &  ".AddCriteria(""schema"",""="", ""1132"");"& vbcrlf
if objFields.Item("FilterBD").Value.Count >0 Then
     if objFields.Item("FilterBD").Value(1) = "Yes" Then
      sQuery = sQuery & "query" & nNumber & ".AddOperator(Query.QueryOperator.AND_Field);"& vbcrlf
         sQuery = sQuery & "query" & nNumber & ".AddCriteria(""categorization"", ""="", ""Broker_Dealer/test"");" & vbcrlf
     End If
End If

While converting this to .net, we added a reference of Tridion.ContentDelivery.DynamicContent dll to our project, so that we can write our code (sample) as:

using Tridion.ContentDelivery.DynamicContent.Query;
Tridion.ContentDelivery.DynamicContent.Query.Query query = new Tridion.ContentDelivery.DynamicContent.Query.Query();
ItemSchemaCriteria isArticle = new ItemSchemaCriteria(1132);
CategoryCriteria bdCategory = new CategoryCriteria("Broker_Dealer/\" + \"test\"");
Criteria bdCriteria = CriteriaFactory.And(isArticle, bdCategory);
query.Criteria = bdCriteria;

This approach is working well in Visual studio so far, but while Building our CT in template builder, we are getting the error "Could not load file or assembly 'Could not load file or assembly 'Tridion.ContentDelivery.Interop, Version=6.1.0.43, Culture=neutral, PublicKeyToken=ddfc895746e5ee6b' or one of its dependencies. The system cannot find the file specified.'

After following these Steps of registering the dlls in GAC, we are still receiving the same problem?

Anything we missed? Kindly help. Thanks.

Huston Lopes
  • 622
  • 4
  • 17
  • 1
    Did you put the Tridion.ContentDelivery.Interop.dll in the bin folder of your web application? – Quirijn Sep 18 '12 at 07:10
  • 1
    Are you using this namespace in a .Net TBB in your CT? If so then you're using it in the wrong place. Tridion.ContentDelivery.DynamicContent is a Content Delivery namespace (the clue's in the name) and shouldn't be used directly in templates. – Jeremy Grand-Scrutton Sep 18 '12 at 07:43
  • Hi Quirijn: Yes, the file is already present in Bin Folder. @Jeremy: Is there any alternative? I need to use the query class (as it can be seen in my post). How can use the query class in my Templates? – Huston Lopes Sep 18 '12 at 08:17
  • 2
    @HustonLopes It does not make sense to use query class in Template code. I hope you understand Query class is to get data from the content delivery system and templatig code work on CMS system during publishing. Anyway what you want to achieve? – vikas kumar Sep 18 '12 at 08:33
  • @vikaskumar : Yes right, I am passing the code as a string in StringBuilder in my template. But for testing purpose, I have added the Query code to my templates, so that I can build my string easily. – Huston Lopes Sep 18 '12 at 08:40

2 Answers2

4

If you need to query the Broker then a .Net TBB is not the place to do it. In your VBSscript template you appear to have been writing server-side code to your output, which is the correct approach. In your modular template you should take the same approach - either write out the appropriate .Net code or, probably a better approach, write out a .Net control tag which, when processed by IIS, will call the CD API directly.

Jeremy Grand-Scrutton
  • 2,802
  • 14
  • 20
  • Hi Jeremy, I am following the same approach as our old CT has. However, since query mechanism is replaced by Broker Query Mechanism, I was trying to find some replacement methods for 'Query.Match, Query.AddSelectString' , a replacement for SearchFilter etc. – Huston Lopes Sep 18 '12 at 08:56
  • Your question doesn't reflect this. In this situation I generally create a page on my web server (CD instance) and write the CD code directly in there. Once I have it working I then reverse-engineer it back in to my templates as appropriate. If you're having problems with the API then ask another, more specific question. – Jeremy Grand-Scrutton Sep 18 '12 at 09:06
  • Thanks Jeremy, one of the question is already here: http://stackoverflow.com/questions/12390664/tridion-replacement-for-query-queryoperator-method/12392198#comment16759595_12392198 – Huston Lopes Sep 18 '12 at 09:14
1

If you are sure that the Interop dll is present in the bin folder, the only thing I can think of is that it is the wrong version. Can you make sure that the DLL has the version 6.1.0.43?

Quirijn
  • 3,549
  • 15
  • 30
  • Yes verified :) I am not testing this method now :( . Instead will concentrate on Building the .net string as suggested by Jeremy. – Huston Lopes Sep 18 '12 at 09:03