views:

130

answers:

2

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.

A: 

What version of SAS are you using? Starting with 9.13, WorkspaceManager is deprecated in favor of ObjectManagerMulti (or ObjectManagerMulti2 in 9.2). I'm not sure this would solve your error though.

Zach
Version 8, sorry.
eftpotrm
A: 

Is the asp server on another machine. If so, and possibly anyway, you will need to license SAS Integration Technologies. See the online documentation for gory details.

Jonathan Goldberg
Thanks and yes. I'm fairly sure it's not a licensing issue or similar though because the same code works when run from a Windows Forms app. It only breaks when run in ASP.Net app.
eftpotrm