Hi all
I've been asked to read some data from SAS in an ASP.Net application. I've got working code for a Windows Forms app. However the same code doesn't work in ASP.Net however I can try it. A clean project with the same references consistently fails.
Here's what I've got for the connection:
SASWorkspaceManager.WorkspaceManager oWorkspaceManager
= new SASWorkspaceManager.WorkspaceManager();
string xmlInfo = "";
SASWorkspaceManager.ServerDef oServerDef = new SASWorkspaceManager.ServerDef();
oServerDef.MachineDNSName = "server";
oServerDef.Protocol = SASWorkspaceManager.Protocols.ProtocolBridge;
oServerDef.Port = <port>;
oServerDef.BridgeEncryptionAlgorithm = "SASProprietary";
oServerDef.BridgeEncryptionLevel =
SASWorkspaceManager.EncryptionLevels.EncryptUserAndPassword;
SAS.Workspace oSASWorkspace =
oWorkspaceManager.Workspaces.CreateWorkspaceByServer ("",
SASWorkspaceManager.Visibility.VisibilityProcess, oServerDef, "user",
"pass", out xmlInfo);
oSASWorkspace.LanguageService.Submit(
"proc means data = sashelp.class;output out=meanout;run;");
OleDbDataAdapter oOleDbDataAdapter = new OleDbDataAdapter
("select * from work.meanout",
"provider=sas.iomprovider.1; SAS Workspace ID=" +
oSASWorkspace.UniqueIdentifier);
DataSet oDS = new DataSet();
oOleDbDataAdapter.Fill(oDS, "sasdata");
oWorkspaceManager.Workspaces.RemoveWorkspaceByUUID(
oSASWorkspace.UniqueIdentifier);
oSASWorkspace.Close();
With just that it fails initialising the data adapter with an inner exception of "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." If I add Trust=Full to the web.config file I get the same error directly when filling the data adapter. We can prove that executing the SAS command via the workspace manager is working, it's when we then try to read the results back that it fails when initialising the connection to SAS. For whatever reason, the fragment
OleDbDataAdapter oOleDbDataAdapter = new OleDbDataAdapter
(<Read Command>,
"provider=sas.iomprovider.1; SAS Workspace ID=" +
oSASWorkspace.UniqueIdentifier);
which seems to be cited everywhere as how to do it just keeps raising an error when run through ASP.Net.
I'm guessing it's a user permissions issue somewhere with it not liking running under the IIS user but wouldn't know what needs permissions granted to it. Some SAS documentations somewhere or other (sorry, can't find it) suggested making sure the user had permissions, but the ASPNET user does have full access to the whole SAS program directory on the dev machine. Does anyone know what else I might need to set? Thanks.