C# 类型或命名空间名称';系统&x27;找不到(是否缺少using指令或程序集引用?)
我正在尝试创建一个web浏览器应用程序,但当我重新启动Visual Studio Community 2019时,它显示了大约500个错误,例如找不到类型或命名空间名称“System”(是否缺少using指令或程序集引用?) 我尝试过几次重新加载VisualStudioCommunity2019,但仍然不起作用 一些项目信息:C# 类型或命名空间名称';系统&x27;找不到(是否缺少using指令或程序集引用?),c#,.net,C#,.net,我正在尝试创建一个web浏览器应用程序,但当我重新启动Visual Studio Community 2019时,它显示了大约500个错误,例如找不到类型或命名空间名称“System”(是否缺少using指令或程序集引用?) 我尝试过几次重新加载VisualStudioCommunity2019,但仍然不起作用 一些项目信息: 目标框架:.NET framework 4.8 使用的NuGet软件包:EasyTabs、CefSharp.WinForm 使用系统; 使用System.Collec
- 目标框架:.NET framework 4.8
- 使用的NuGet软件包:EasyTabs、CefSharp.WinForm
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows.Forms;
使用头孢沙普;
使用CefSharp.WinForms;
使用EasyTabs;
在我发布问题之前,我发现您需要使用.NET Framework 4.7.2来解决此问题。因此您使用的是easy tabs,我为您准备了代码。创建新的windows窗体项目,在该项目中创建另一个窗体并使用CAP和所有内容将其重命名为AppContainer,然后使用framework 4.7.2打开应用程序容器,然后键入C#代码
同样在上面,它说使用请使用EasyTabs键入,然后使用CefSharp键入。基本上,您使用的每个包代码都需要引用该包,然后为浏览器添加一个副标题。接下来打开Form1.cs并键入此代码
// 2. Important: Declare ParentTabs
protected TitleBarTabs ParentTabs
{
get
{
return (ParentForm as TitleBarTabs);
}
}
例如,在代码的名称空间为的位置键入
namespace YOUR_PROGRAM_NAME_HERE
{
public partial class Form1 : Form
{
// 2. Important: Declare ParentTabs
protected TitleBarTabs ParentTabs
{
get
{
return (ParentForm as TitleBarTabs);
}
}
public object HTMLcodeec { get; }
public Form1()
{
InitializeComponent();
}
现在,进入解决方案资源管理器中的program.cs文件并单击它。您是否需要键入以下代码
namespace YOUR_PROGRAM_NAME_HERE
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
AppContainer container = new AppContainer();
// Add the initial Tab
container.Tabs.Add(
// Our First Tab created by default in the Application will have as
content the Form1
new TitleBarTab(container)
{
Content = new Form1
{
Text = "New Tab"
}
}
);
// Set initial tab the first one
container.SelectedTabIndex = 0;
// Create tabs and start application
TitleBarTabsApplicationContext applicationContext = new
TitleBarTabsApplicationContext();
applicationContext.Start(container);
Application.Run(applicationContext);
}
}
}
在您执行任何操作之前,请将cefsharp和easy选项卡下载到您的项目中
如果你想看到我的浏览器项目,我建立去,你可以看到我做了什么
这是一个.exe文件,你可以下载“如果你需要更多帮助,请订阅我的youtube频道,因为我会很快就这个主题制作视频”
namespace YOUR_PROGRAM_NAME_HERE
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
AppContainer container = new AppContainer();
// Add the initial Tab
container.Tabs.Add(
// Our First Tab created by default in the Application will have as
content the Form1
new TitleBarTab(container)
{
Content = new Form1
{
Text = "New Tab"
}
}
);
// Set initial tab the first one
container.SelectedTabIndex = 0;
// Create tabs and start application
TitleBarTabsApplicationContext applicationContext = new
TitleBarTabsApplicationContext();
applicationContext.Start(container);
Application.Run(applicationContext);
}
}
}
ChromiumWebBrowser Browser;
private void Form1_Load(object sender, EventArgs e)
{
CefSettings settings = new CefSettings();
//Initialize
CefSharpSettings.LegacyJavascriptBindingEnabled = true; // Enable Register JS Object, -- RegisterAsyncJsObject, RegisterJsObject allow
settings.CachePath = "cache";
settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //Enable WebRTC4
settings.CefCommandLineArgs.Add("disable-gpu", "1");
settings.CefCommandLineArgs.Add("disable-gpu-compositing", "1");
BrowserSettings browserSettings = new BrowserSettings
{
FileAccessFromFileUrls = CefState.Enabled,
UniversalAccessFromFileUrls = CefState.Enabled,
WebSecurity = CefState.Enabled,
WebGl = CefState.Enabled,
BackgroundColor = (uint)CefState.Enabled,
};
Browser = new ChromiumWebBrowser(AddressText.Text);
this.pContainer.Controls.Add(Browser);
Browser.DownloadHandler = new DownloadHandler();
Browser.Dock = DockStyle.Fill;
Browser.Load("https://ask.com/");
this.AcceptButton = this.NavigateToURL;
Browser.AddressChanged += Browser_AddressChanged;
Browser.TitleChanged += Browser_TitleChanged;
}