No method in C# but exists in VB?

  • Thread starter Thread starter Brett
  • Start date Start date
B

Brett

Sorry for all the post on conversion from VB.NET to C#. Just can't figure
some of these out. getElementsByTagName method is fine in VB but get this
error in C#:

Object does not contain a signature for getElementsByTagName

Intellisense in both langauges is the same.

[VB.NET]
Private WithEvents IE_Inst As New SHDocVw.InternetExplorer
Dim wbrAll As mshtml.IHTMLElementCollection = _
Me.IE_Inst.Document.("input")

[C#]
private SHDocVw.InternetExplorer IE_Inst = new SHDocVw.InternetExplorer();
this.IE_Inst.Document.getElementsByTagName("input");

What did I miss in C# that VB.NET picked up?

Thanks,
Brett
 
C# is casse sentitive - Did you mean to use a capital G at the start of the method name?

Regards

RIchard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Sorry for all the post on conversion from VB.NET to C#. Just can't figure
some of these out. getElementsByTagName method is fine in VB but get this
error in C#:

Object does not contain a signature for getElementsByTagName

Intellisense in both langauges is the same.

[VB.NET]
Private WithEvents IE_Inst As New SHDocVw.InternetExplorer
Dim wbrAll As mshtml.IHTMLElementCollection = _
Me.IE_Inst.Document.("input")

[C#]
private SHDocVw.InternetExplorer IE_Inst = new SHDocVw.InternetExplorer();
this.IE_Inst.Document.getElementsByTagName("input");

What did I miss in C# that VB.NET picked up?

Thanks,
Brett
 
Tried that but it doesn't work either. Any other suggestions?

Thanks,
Brett
 
The method is definitely GetElementsByTagName(string tagName)
What's the exact compiler error message?

Willy.


Brett said:
Tried that but it doesn't work either. Any other suggestions?

Thanks,
Brett
Richard Blewett said:
C# is casse sentitive - Did you mean to use a capital G at the start of
the method name?

Regards

RIchard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Sorry for all the post on conversion from VB.NET to C#. Just can't
figure
some of these out. getElementsByTagName method is fine in VB but get this
error in C#:

Object does not contain a signature for getElementsByTagName

Intellisense in both langauges is the same.

[VB.NET]
Private WithEvents IE_Inst As New SHDocVw.InternetExplorer
Dim wbrAll As mshtml.IHTMLElementCollection = _
Me.IE_Inst.Document.("input")

[C#]
private SHDocVw.InternetExplorer IE_Inst = new
SHDocVw.InternetExplorer();
this.IE_Inst.Document.getElementsByTagName("input");

What did I miss in C# that VB.NET picked up?

Thanks,
Brett
 
If I use capital G, it says object does not contain a definition for ...
Here is the error with lower case G:

C:\myFiles\MailC#\Main\IE.cs(81): 'object' does not contain a definition for
'getElementsByTagName'

Willy Denoyette said:
The method is definitely GetElementsByTagName(string tagName)
What's the exact compiler error message?

Willy.


Brett said:
Tried that but it doesn't work either. Any other suggestions?

Thanks,
Brett
Richard Blewett said:
C# is casse sentitive - Did you mean to use a capital G at the start of
the method name?

Regards

RIchard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Sorry for all the post on conversion from VB.NET to C#. Just can't
figure
some of these out. getElementsByTagName method is fine in VB but get
this
error in C#:

Object does not contain a signature for getElementsByTagName

Intellisense in both langauges is the same.

[VB.NET]
Private WithEvents IE_Inst As New SHDocVw.InternetExplorer
Dim wbrAll As mshtml.IHTMLElementCollection = _
Me.IE_Inst.Document.("input")

[C#]
private SHDocVw.InternetExplorer IE_Inst = new
SHDocVw.InternetExplorer();
this.IE_Inst.Document.getElementsByTagName("input");

What did I miss in C# that VB.NET picked up?

Thanks,
Brett
 
Brett said:
If I use capital G, it says object does not contain a definition for ...
Here is the error with lower case G:

C:\myFiles\MailC#\Main\IE.cs(81): 'object' does not contain a definition
for 'getElementsByTagName'


Sorry looking in the wrong namespace for getElementsByTagName.
'object' does not contain .. means this.IE_Inst.Document returns an Object
type, VB has better support for this late binding stuff (using reflection),
in C# you have to cast the object to the right Interface like this ...


object o = null;
IEDocvw.InternetExplorer ie = new IEDocvw.InternetExplorer();
IWebBrowserApp wb = ie as IWebBrowserApp;
wb.Navigate("http://xxxxx", ref o, ref o, ref o, ref o);
wb.Visible = false;
HTMLDocument wd = (HTMLDocument)wb.Document;
IHTMLElementCollection ic = wd.getElementsByTagName("input");
Console.WriteLine(ic.length);

Willy.
 
Willy Denoyette said:
Sorry looking in the wrong namespace for getElementsByTagName.
'object' does not contain .. means this.IE_Inst.Document returns an Object
type, VB has better support for this late binding stuff (using
reflection), in C# you have to cast the object to the right Interface like
this ...


object o = null;
IEDocvw.InternetExplorer ie = new IEDocvw.InternetExplorer();
IWebBrowserApp wb = ie as IWebBrowserApp;
wb.Navigate("http://xxxxx", ref o, ref o, ref o, ref o);
wb.Visible = false;
HTMLDocument wd = (HTMLDocument)wb.Document;
IHTMLElementCollection ic = wd.getElementsByTagName("input");
Console.WriteLine(ic.length);

Willy.

Thanks. It is working now. Nice.

How about this one:

object novar1;
object novar2;
IE_Inst.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, novar1, novar2);

I think the problem is on those last two arguments. No matter what I use, I
get this error:

The best overloaded method match for
'SHDocVw.IWebBrowser2.ExecWB(SHDocVw.OLECMDID, SHDocVw.OLECMDEXECOPT, ref
object, ref object)' has some invalid arguments

Any ideas?

Brett
 
Brett said:
Thanks. It is working now. Nice.

How about this one:

object novar1;
object novar2;
IE_Inst.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, novar1, novar2);

I think the problem is on those last two arguments. No matter what I use,
I get this error:

The best overloaded method match for
'SHDocVw.IWebBrowser2.ExecWB(SHDocVw.OLECMDID, SHDocVw.OLECMDEXECOPT, ref
object, ref object)' has some invalid arguments

Any ideas?

Brett

Check your error message, you need to pass a reference.
..... ref object, ref object)

Willy.
 
Willy Denoyette said:
Check your error message, you need to pass a reference.
.... ref object, ref object)

Willy.

Very cool Willy. Error went away. I am still passing in empty objects:
object novar1;
object novar2;

Is there a better way or is this acceptable?

Here's one more that I'm having trouble with. Again, a VB.NET to C#
conversion:
[VB.NET]
Dim UDCPrinter As New UDCWRAPPERLib.Printer
Dim UDCProfile As UDCWRAPPERLib.Profile

UDCPrinter.PrinterName = "Universal Document Converter"
UDCProfile = UDCPrinter.Profile(UDCPrinter.DefaultProfile)

[C#}
UDCWRAPPERLib.Printer UDCPrinter = new UDCWRAPPERLib.Printer();
UDCWRAPPERLib.Profile UDCProfile;

UDCPrinter.PrinterName = "Universal Document Converter";
UDCProfile = UDCPrinter.get_Profile();

Error is on the last line:
No overload for method 'get_Profile' takes '0' arguments

Object browser tree looks like this:
UDCWRAPPERLib
Printer (interface)
IPrinter (interface)

get_Profile(string) is a member of the last node.

I'm using get_Profile because .Profile isn't available in C#. Why does the
above error occur is "string" type is required?

I have tried:
UDCProfile = UDCPrinter.get_Profile(UDCPrinter.DefaultProfile);
and get:
Cannot implicitly convert type 'object' to 'UDCWRAPPERLib.Profile'

Any suggestions?

Thanks,
Brett
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top