I love LINQPad! I'm trying to connect to Tridion Core Services using a WCF connector in LINQPad to help with my rapid development & learning of Core.
Currently, LINQPad is reporting a 404 (not found) error for the URI, but this same URI works in my browser.
Anyone else successfully connect?
LINQPad's connection window
LINQPad is by now my tool of choice for interacting with Tridion through its Core Service API.
If you just download a plain LINQPad, it can connect to WCF data services (typically known as OData sources), SQL Server databases and to the Azure Data Services market. Since Tridion's Core Service is none of those types, you can not create a persistent connection to it.
But you can still use LINQPad as a lightweight alternative to Visual Studio by following these steps:
LINQPad can handle multiple languages. It defaults to "C# Expression", which means you can just specify a single "statement" in the code panel. That works great when working with e.g. SQL databases for which a driver is available, but is not good enough for interacting with Tridion's Core Service. So first you need to switch it from "C# Expression" language to "C# Program" language in the toolbar at the top of your query.
After switching Language, I typically start with the following boilerplate
void Main()
{
// System.Runtime.Serialization.dll
// System.ServiceModel.dll
// System.Net.dll
// Namespaces:
// System.Net
// System.ServiceModel
// Tridion.ContentManager.CoreService.Client
var binding = new NetTcpBinding { MaxReceivedMessageSize = 2147483647, ReaderQuotas = new XmlDictionaryReaderQuotas { MaxStringContentLength = 2147483647, MaxArrayLength = 2147483647 } };
var endpoint = new EndpointAddress("net.tcp://<hostname>:2660/CoreService/2011/netTcp");
var DEFAULT_READ_OPTIONS = new ReadOptions();
CoreServiceClient client = new CoreServiceClient(binding, endpoint);
client.ChannelFactory.Credentials.Windows.ClientCredential = new NetworkCredential("<username>", "<password>");
try {
// TODO: fill in the blanks
} finally {
if (client.State == CommunicationState.Faulted) client.Abort(); else client.Close();
}
}
After pasting this code, open the Query Properties window (F4) and add System.Runtime.Serialization.dll
, System.ServiceModel.dll
and System.Net.dll
to the Additional References tab. Make sure you have a copy of Tridion.ContentManager.CoreService.Client.dll on your machine and add a reference to that too. (You can find this in Tridion/bin/client on your server)
Add System.Net
, System.ServiceModel
and Tridion.ContentManager.CoreService.Client
to the Additional Namespace Imports tab.
Change the <hostname>
, <username>
and <password>
values in the code and test if the connection succeeds.
After this, fill in the blanks and start having fun with the Core Service API.
I recommend keeping the Core Service API documentation (in CHM format) open at all times. With that open I found that I could get pretty far even without auto-complete. And if you save the query you just created, you can easily clone it with ctrl-shift-C and have a fresh query with the Language, DLL references and Namespaces already filled in.
A easier way to connect to Tridion from LINQPad is now documented here: https://sdltridionworld.com/articles/sdltridion2011/using_linqpad_with_tridion.aspx
Reading through this: http://markistaylor.com/2010/09/09/linqpad-beyond-linq/ it seems like you might be able to do this by adding a reference to System.ServiceModel.dll and [Tridion_Home]\bin\client\Tridion.ContentManager.CoreService.Client.dll (under Query -> Query Properties) to LINQPad.
You can check the IIS log for the Content Manager - do you see the 404 from the LINQPaD connection attempt? Does the page actually exist?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With