'SSIS Script Transformation Editor -type or namespace name 'WebScrape' could not be found are you missing a using directive or an assembly reference?
I'm using VS 2019 with SQL Server 2017. I have a SSIS Package and a Script Transformation Editor that is executing some c# code.
This is the main.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);
}
}
}
This is the 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;
}
}
}
When I try to build the project I keep receiving the error in the Main.cs:
Severity Code Description Project File Line Suppression State Error The type or namespace name 'WebScrape' could not be found (are you missing a using directive or an assembly reference?)
Why is it complaining? I have a WebScrape class created and I'm referencing WebScrape in the Namespace in Main. I have also tried referencing the fully qualified namespace in Main.cs to no avail:
using WebScrape.SC_68c409392de64cb2b3012e25a1dc514c;
What am I missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
