Question

I migrated Mining Structures from a 2008 server to a 2012 server. When I try my CLR UDF (which is working fine on SQL server 2008) in a DMX query on the 2012 server, I am getting this error:

Exception has been thrown by the target of an invocation. Object reference not set to an instance of an object.

My original goal was to get the GetNodeDescription(...) method running. While debugging the problem, I could isolate the problem to this UDF which fails on my SQL server 2012

[SafeToPrepare(true)]
public static string test()
{
  return Context.CurrentMiningModel.Name;
}

My guess is that CurrentMiningModel is null because the following code works fine

[SafeToPrepare(true)]
public static string testUser()
{
 return Context.CurrentConnection.User.Name;
}

Any Idea on how to solve this? Is somebody out there who can reproduce this?

Thanks.

Jan

UPDATE: A contact at Microsoft confirmed this behaviour as desired due to a "Metadata-Refactoring" (whatever this means...). However, the website still pends to be updated appropiately.

Was it helpful?

Solution

This is not the ultimate answer but it's a workaround to get Microsoft's GetNodeDescription working (by explicitly providing the mining model):

[SafeToPrepare(true)]  
public static string GetNodeDescription(string MiningModel, string nodeUniqueName)  
{  
  if (Context.ExecuteForPrepare)  
  {
    return string.Empty;  
  }  
  return Context.MiningModels[MiningModel].GetNodeFromUniqueName(nodeUniqueName).Descript‌​ion;  
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top