问题描述
有人要求我在 ASP.Net 应用程序中从 SAS 读取一些数据.我有一个 Windows 窗体应用程序的工作代码.然而,相同的代码 不 在 ASP.Net 中工作,但我可以尝试.具有相同引用的干净项目始终失败.
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.
这是我为连接准备的:
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();
只是它无法初始化数据适配器,内部异常为试图读取或写入受保护的内存.这通常表明其他内存已损坏."如果我将 Trust=Full 添加到 web.config 文件中,则在填充数据适配器时会直接收到相同的错误.我们可以证明通过工作空间管理器执行 SAS 命令是有效的,当我们尝试读取结果时,它在初始化与 SAS 的连接时失败.无论出于何种原因,片段
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);
这似乎到处都被引用为如何做到这一点只是在通过 ASP.Net 运行时不断引发错误.
which seems to be cited everywhere as how to do it just keeps raising an error when run through ASP.Net.
我猜这是某个地方的用户权限问题,它不喜欢在 IIS 用户下运行,但不知道需要授予它什么权限.某处或其他地方的一些 SAS 文档(抱歉,找不到)建议确保用户具有权限,但 ASPNET 用户确实可以完全访问开发机器上的整个 SAS 程序目录.有谁知道我还需要设置什么?谢谢.
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.
推荐答案
我在 IIS 中运行类似的东西时遇到了几个问题.首先,您必须在管理工具 -> 组件服务中调整 SAS 工作区组件的权限.您必须为运行您的应用程序池的用户添加权限.这将在组件的属性窗口 -> 安全选项卡 -> 启动和激活权限以及访问权限下.
I ran into a couple of issues when running something similar in IIS. First, you'll have to adjust the permissions on the SAS Workspace component in admin tools -> component services. You'll have to add permissions for the user that your application pool is running under. This will be under the properties windows of the component -> security tab -> launch and activation permissions, and also the access permissions.
我还不得不修改配置中的 SASUSER 目录,因为网络服务没有访问权限.
I also ended up having to modify the SASUSER directory in the config because network service didn't have access.
C:Program FilesSASHomeSASFoundation9.3 lsensasv9.cfg
C:Program FilesSASHomeSASFoundation9.3 lsensasv9.cfg
/*-SASUSER "?CSIDL_PERSONALMy SAS Files9.3" */-SASUSER "c:sasuser"
/*-SASUSER "?CSIDL_PERSONALMy SAS Files9.3" */ -SASUSER "c:sasuser"
这篇关于从 .Net 中的 SAS 数据源读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!