Saturday, May 26, 2012
MDS .net Assembly Error "The Microsoft SQL Server license has expired"
I was trying to get MDS assemblies going.
File Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Collections.ObjectModel;
using Microsoft.MasterDataServices.Deployment;
using Microsoft.MasterDataServices.Services.DataContracts;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
//Reads a model's metadata, business rules, and master data
ModelReader reader = new ModelReader();
Console.WriteLine(reader.CurrentUser.DisplayName);
Console.WriteLine("Models:");
Collection<identifier> models = reader.GetModels();
foreach (Identifier modelId in models)
{
Console.WriteLine(modelId.Name);
}
}
catch(System.Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
Console.ReadKey();
}
}
}
App.Config
<configuration>
<configsections>
</configsections>
<connectionstrings>
<add connectionstring="Data Source=localhost;Initial Catalog=MDS_2012;Integrated Security=True" name="defaultMdsConnection" providername="System.Data.SqlClient">
</add></connectionstrings>
</configuration>
referencing the following assemblies from
C:\Program Files\Microsoft SQL Server\110\Master Data Services\WebApplication\bin
Microsoft.MasterDataServices.Core
Microsoft.MasterDataServices.Deployment
Microsoft.MasterDataServices.Services
Microsoft.MasterDataServices.Services.Contracts
When running the app I get the following error:
Olof Szymczak
Models:
Error: The Microsoft SQL Server license has expired.
When using reflector, I find that the following method throws the error
File: Services.cs
Namespace: namespace Microsoft.MasterDataServices.Services
Method:
private static void CheckExpiration()
{
if (isExpired)
{
Microsoft.MasterDataServices.Core.Log.Write(LogMessageType.Error, "Evaluation period has expired.");
EditionExpiredMessage detail = new EditionExpiredMessage();
FaultException<editionexpiredmessage> exception = new FaultException<editionexpiredmessage>(detail, ErrorStrings.EvaluationExpired);
throw exception;
}
}
It looks like isExpired is set to true. So I looked for the method that is setting isExpired. Drilling in that method I find:
File: Utility.cs
Namespace: Microsoft.MasterDataServices.Core.BusinessEntities
Method: private static QuerySkuValue LoadQuerySkuValueMethod()
in the method it is trying to load a dll C:\Program Files\Microsoft SQL Server\110\Shared\sqlboot.dll
zero = LoadLibraryW(dllname); //this fails to load the dll
Checked the location and the dll exists.
Note if I set isExpired = false while debugging the code. I get the correct results.
Eventually I found the answer after downloading http://archive.msdn.microsoft.com/ModelDApiSample, modifing it to point to the MDS 2012 assemblies and reconfiguring the config file. I run it and it worked, I was going WTF. So I checked what was wrong with my project settings, the answer x86, the project.Build.Platform target has to be set to either x64 or Any CPU.
All I can say is what a great way of telling you, that you have compiled the code for the wrong platform by returning an error of "The Microsoft SQL Server license has expired".
Subscribe to:
Posts (Atom)