提问人:Michael 提问时间:1/25/2022 最后编辑:Michael 更新时间:1/25/2022 访问量:62
找不到 SSIS 脚本转换编辑器 - 类型或命名空间名称“WebScrape”,是否缺少 using 指令或程序集引用?
SSIS Script Transformation Editor -type or namespace name 'WebScrape' could not be found are you missing a using directive or an assembly reference?
问:
我正在将 VS 2019 与 SQL Server 2017 一起使用。我有一个 SSIS 包和一个正在执行一些 c# 代码的脚本转换编辑器。
这是主要的 .cs:
#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Windows.Forms;
using WebScrape;
#endregion
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
public override void PreExecute()
{
base.PreExecute();
/*
* Add your code here
*/
}
public override void PostExecute()
{
base.PostExecute();
/*
* Add your code here
*/
}
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
try
{
WebScrape WBScrape = new WebScrape();
Row.DescriptionText = WBScrape.read_text_page(Row.Links);
}
catch (Exception UnknownError1)
{
MessageBox.Show(UnknownError1.Message);
}
}
}
这是WebScrape.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SC_68c409392de64cb2b3012e25a1dc514c
{
class WebScrape
{
const string HTML_TAG_PATTERN = @"(<(!--|script) (.|\n[^<]) * (--|script)>)|(<|<) (/?[\w!?]+)\s?[^<]*(>|>)|(\&[\w]+\;)";
private string StripHTML(string inputString)
{
return Regex.Replace(inputString, HTML_TAG_PATTERN, string.Empty);
}
public string read_text_page (string pagelink)
{
string tempstring = string.Empty;
int count = 0;
string hold_temp_values = string.Empty;
// used to build entire input
StringBuilder sb = new StringBuilder();
//used on each read operation
byte[] buf = new byte[8192];
//prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(pagelink);
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36";
// execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// we will read data via the response stream
Stream resStream = response.GetResponseStream();
do
{
// fill the buffer with data
count = resStream.Read(buf, 0, buf.Length);
// make sure we read some data
if (count != 0)
{
//transalate from bytes to ASCII text
tempstring = Encoding.ASCII.GetString(buf, 0, count);
// continue building the string
sb.Append(tempString);
}
}
while (count > 0); // any more data to read?
hold_temp_values = StripHTML(sb.ToString()).Trim();
if (hold_temp_values.Length > 8000)
{
hold_temp_values = hold_temp_values.Substring(0, 8000);
}
else
{
}
return hold_temp_values;
}
}
}
当我尝试构建项目时,我在 Main.cs 中不断收到错误:
严重性代码说明 项目文件行抑制状态 错误:找不到类型或命名空间名称“WebScrape”(是否缺少 using 指令或程序集引用?
为什么抱怨?我创建了一个 WebScrape 类,并在 Main 的命名空间中引用了 WebScrape。我还尝试在 Main.cs 中引用完全限定的命名空间,但无济于事:
using WebScrape.SC_68c409392de64cb2b3012e25a1dc514c;
我错过了什么?
答: 暂无答案
评论