1

Edited to add solution: changed to use the constructor that takes a Microsoft.Xrm.Client.CrmConnection rather that a String connection string and it works.

I used the crmsvcutil.exe to generate the data context for our crm environment. When I try to initialize the connection. This line: public CSIDataContext(global::System.String name) : base(name)

throws this error: Unable to load the connection string name 'Authentication Type=AD; Server=/rest of conn string is here/'

This code resides in a BizLayer class library project and is being called from a win form test project. If both the generated entities class and the calling code are in the same project, I don't get that error.

Matt
  • 4,656
  • 1
  • 22
  • 32
greg
  • 11
  • 3

1 Answers1

0

It sounds like you're passing the full connection string in the constructor rather than the name of the connection string in the connectionStrings node of the app.config/web.config.

The XRM connection string is very similar to an ADO.NET connection string in that it resides in the element in the app.config/web.config. So, you would normally place the full connection string into your config with a name like so:

<connectionStrings>
    <add name="XrmConnectionString" connectionString="Authentication Type=AD; Server=http://server.com; User ID=Domain\Username; Password=P@$$w0RD"/>
</connectionStrings>

Then, when you want to initialize the XRM context, you just supply the connection string's name:

var dataContext = new XRMDataContext("XrmConnectionString");

Try that and see if it works for you.

Guido Preite
  • 14,905
  • 4
  • 36
  • 65
Jeffrey Harrington
  • 1,797
  • 1
  • 15
  • 24