Tuesday, May 17, 2011

SAS StoredProcessService events

If you encounter the following error when using SAS's StoredProcessService events:

event invocation for COM objects requires event to be attributed with DispIdAttribute

Roll your project back from .NET 4.0 to .NET 3.5. This may only be applicable to the web services code.

Example code:

class Program
{
static void Main(string[] args)
{

Workspace ws = new Workspace();
SAS.LanguageService ls = ws.LanguageService;
ls.StepError += new CILanguageEvents_StepErrorEventHandler(ls_StepError); <---- ERROR OCCURS HERE
ls.Submit("data test; abort; run;");
}
static void ls_StepError()
{
Console.WriteLine("Bingo!");
Console.ReadLine();
}
}

3 comments:

Unknown said...

Alan, I ran this by some colleagues here. In your reference to the SAS Interop assemblies, try changing the "Embed Interop Types" property to False. By default, VS2010 and .NET 4.0 might set them to be True.

Savian said...

Chris,

That did it. Under .NET 4.0, the COM assemblies are marked as Embedded = true.

For people who need to fix this, after adding references to SAS, ObjectManager, IOMCommon, etc., click on the reference, look in properties, and change Embed Interop Types to False.

Eric Webster said...

Awesome! Error hit, blog found, error fixed, total elapsed time under 5 minutes. Thanks, guys!

SAS throwing RPC error

If you are doing code in C#  and get this error when creating a LanguageService: The RPC server is unavailable. (Exception from HRESULT:...