Projekt-Anfragen: Tel: 07022/9319004 info@CodeDocu.de Software Entwicklung in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Fehlermeldung: Cannot convert type 'System.Windows.Forms.HtmlDocument' to 'mshtml.HTMLDocument'
 
 
Error Code: CS0030
 

Severity

Code

Description

Project

Line

Suppression State

Error

CS0030

Cannot convert type 'System.Windows.Forms.HtmlDocument' to 'mshtml.HTMLDocument'

test_winform_Browser

36

Active

 
 
Lösung:
Umwandlung von

doc = (mshtml.HTMLDocument) webBrowser1.Document;

Zu

doc = (mshtml.HTMLDocument) webBrowser1.Document.DomDocument;

 
 
Richtiger C# Code unter WinForms

private async void btnTranslate_Click(object sender, EventArgs e)
{
//*set and get Translation
doc = (mshtml.HTMLDocument) webBrowser1.Document.DomDocument;
set_Translation();
//----< wait 1 second >----
await Task.Delay(1000);
//----</ wait 1 second >----
 
//----< wait doc.complete >----
DateTime dtStart = DateTime.Now;
while (doc.readyState != "complete")
{
if ((DateTime.Now - dtStart).Seconds > 5) break;
await Task.Delay(1);
}
//----</ wait doc.complete >----
 
get_Translation();
//-------------------</ btnTranslate_Click() >-------------------
}

 
 
Fehlerhafter Code: (Übernommen aus einer wpf Anwendung)

 
//< locals >
mshtml.HTMLDocument doc;
//</ locals >
..
private async void btnTranslate_Click(object sender, EventArgs e)
{
//*set and get Translation
doc = (mshtml.HTMLDocument) webBrowser1.Document;
set_Translation();
//----< wait 1 second >----
await Task.Delay(1000);
//----</ wait 1 second >----
 
//----< wait doc.complete >----
DateTime dtStart = DateTime.Now;
while (doc.readyState != "complete")
{
if ((DateTime.Now - dtStart).Seconds > 5) break;
await Task.Delay(1);
}
//----</ wait doc.complete >----
 
get_Translation();
//-------------------</ btnTranslate_Click() >-------------------
}

 
 
Mobile
»
Gelöst: Thread muss der STA-Modus (Single Thread Apartment) festgelegt werden
»
C#, Winforms: error CS1061: PropertyStore enthält keine Definition für Settings
»
Visual Studio Build Fehlermeldung: mismatch between the processor architecture
»
Fehlermeldung: Cannot convert type System.Windows.Forms.HtmlDocument to mshtml.HTMLDocument

.

Jobs, Projekte, Angebote für Freiberufler, Selbstständig an Info@CodeDocu.de