当部署在IIS7 ASP.NET OLEDB code中断 [英] ASP.NET OLEDB code breaks when deployed on IIS7

查看:283
本文介绍了当部署在IIS7 ASP.NET OLEDB code中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个简单的网站(ASP.NET V4),这将调用Windows搜索,找到一个特定的文件,并返回给用户。我已经把以下为例:它的的RemoteServer调用Windows搜索服务,并返回somefile.txt的路径:

I'm trying to write a simple website (ASP.NET v4), which will call Windows Search, find a specific file and return it to the user. I've put together the following as an example: it calls the Windows Search service on "remoteserver", and returns the path of "somefile.txt":

OleDbConnection conn = new OleDbConnection();

conn.ConnectionString = "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';";

OleDbCommand cmd = conn.CreateCommand();


cmd.CommandText = string.Format(
            "SELECT System.ItemPathDisplay, System.ItemType FROM " +
            " sytelhp.systemindex WHERE SCOPE='file://remoteserver/archive' AND CONTAINS(\"System.FileName\", " +
            " '\"*{0}*\"')", "somefile.txt");


conn.Open();

OleDbDataReader rdr = cmd.ExecuteReader();

string result=rdr[0].ToString();

..这适用于Visual Studio 2010的开发环境太棒了,结果包含文件路径。但是,如果我把它部署到本地服务器IIS7(Server 2008上运行),我得到这个错误:

.. and this works great on Visual Studio 2010 development environment, "result" contains the path to the file. However, if I deploy it to the local IIS7 server (running on Server 2008), I get this error:

The parameter is incorrect. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.OleDb.OleDbException: The parameter is incorrect.

我茫然下一步去哪里。我需要做什么做IIS7,或code,或两者都搞不定?同样,这个工程中VS2010(包括Windows 7和Windows 2008服务器上测试)的罚款。

I'm at a loss where to go next. What do I need to do to IIS7, or the code, or both to get it working? Again, this works fine within VS2010 (tested on both Windows 7 and Windows 2008 Server).

推荐答案

我猜你是在Vista或旧操作系统运行,并且运行IIS 2008服务器或更新版本吗?
尝试提供程序= Search.Collat​​orDSO.1 (注意在 .1 )。

I guess you are running on Vista or older OS and the IIS runs on 2008 Server or newer? Try Provider=Search.CollatorDSO.1 (note the .1).

修改:你应该使用不同的用户帐户的搜索工作(而不是默认的网络服务一个asp.net应用程序下运行)。查看评论获取更多信息。

Edit: You should use a different user account for the search to work (not the default "network service" one the asp.net app runs under). See the comments for more info.

这篇关于当部署在IIS7 ASP.NET OLEDB code中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆