dumb question

  • Thread starter Thread starter GS
  • Start date Start date
G

GS

in VS .net vb 2005 express,
I failed to find the option for leaving out warning in the Errors tab but
still leave Warning in the warning tab listing.

Can someone give me some hints? thank you for your time and advice
 
What kind of warnings are you getting? It might be a good idea to
address them, as warnings tend to turn into runtime errors.

Thanks,

Seth Rowe
 
Warning 1 Access of shared member, constant member, enum member or nested
type through an instance;
qualifying expression will not be evaluated.
D:\data\IeI\gp\AppCom\myApp\FormmyApp.vb 674 29 myApp

the code
Private Sub openMI_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles openMI.Click
Dim od As New OpenDialog()

Dim myDialogResult As DialogResult = od.ShowDialog(Me)
If myDialogResult = DialogResult.OK Then
ShowUrl(od.PathOrUrl)
End If
End Sub

the above code is from some example on WebOChost control, Since there is no
plan to use it and don't know how to fix it, I just want to ignore it for
now

The reason I want to separate listing of error and warning is that I can
quickly address the errors first during developement and as long as the
number of the warning
in the warning tab reamins same I would ignore for now. they are either
from OLE structure or like the above - not critical now

I am trying come up with a quick runnable demo of concepts

Warning 2 Type of member 'cmdtextf' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\OleCommandTarget.vb 5 12 myApp
Public Event CommandStateChange(ByVal Sender As Object, ByVal E As
AxSHDocVw.DWebBrowserEvents2_CommandStateChangeEvent)

Warning 1 Access of shared member, constant member, enum member or nested
type through an instance; qualifying expression will not be evaluated.
D:\data\IeI\gp\AppCom\myApp\FormmyApp.vb 674 29 myApp
Warning 2 Type of member 'cmdtextf' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\OleCommandTarget.vb 5 12 myApp
Warning 3 Type of member 'cwActual' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\OleCommandTarget.vb 6 12 myApp
Warning 4 Type of member 'cwBuf' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\OleCommandTarget.vb 7 12 myApp
Warning 5 Type of member 'cmdf' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\OleCommandTarget.vb 14 12 myApp
Warning 6 Type of parameter 'cCmds' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\OleCommandTarget.vb 27 56 myApp
Warning 7 Access of shared member, constant member, enum member or nested
type through an instance; qualifying expression will not be evaluated.
D:\data\IeI\gp\AppCom\myApp\OpenDialog.vb 162 27 myApp
Warning 8 Type of parameter 'E' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\WebOCHostCtrl.vb 15 67 myApp
Warning 9 Type of parameter 'e' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\WebOCHostCtrl.vb 20 65 myApp
Warning 10 Type of parameter 'e' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\WebOCHostCtrl.vb 21 73 myApp


Warning 11 Type of parameter 'e' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\WebOCHostCtrl.vb 22 74 myApp
Public Event TopLevelNavigateComplete2(ByVal sender As Object, ByVal e
As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event)

Warning 12 Return type of function 'HtmlDocument' is not CLS-compliant.
D:\data\IeI\gp\AppCom\myApp\WebOCHostCtrl.vb 131 30 myApp
Public ReadOnly Property HtmlDocument() As mshtml.HTMLDocument
the below are used in webBrowser's OLE execute command like
Dim cmdt As IOleCommandTarget
Dim o As Object

' If the doc object isn't set to anything, or there's
' some bizarre error in accessing IOleCommandTarget,
' exit gracefully.
Try
cmdt = CType(doc, IOleCommandTarget)
cmdt.Exec(cmdGUID, MiscCommandTarget.ViewSource,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, o, o)
Catch
Throw (New Exception(Err.GetException().Message))
End Try

Warning 14 Variable 'o' is passed by reference before it has been assigned a
value. A null reference exception could result at runtime.
D:\data\IeI\gp\AppCom\myApp\WebOCHostCtrl.vb 247 109 myApp
Warning 15 Variable 'o' is passed by reference before it has been assigned a
value. A null reference exception could result at runtime.
D:\data\IeI\gp\AppCom\myApp\WebOCHostCtrl.vb 262 103 myApp
Warning 16 Variable 'o' is passed by reference before it has been assigned a
value. A null reference exception could result at runtime.
D:\data\IeI\gp\AppCom\myApp\WebOCHostCtrl.vb 277 106 myApp
 
That's a lot of warnings! I'll take a better look later but here's some
of the warnings you should fix:
Warning 1 Access of shared member, constant member, enum member or nested
type through an instance;

Shared methods operate independantly from an instance's methods, and
aren't available to an instance of the class. This warning tells you
that you are trying to access a shared method and that it's not
evaluating the code. You'll want to call the method through the class
instead of an instance.
Warning 16 Variable 'o' is passed by reference before it has been assigned a
value. A null reference exception could result at runtime.

Without seeing all your code it's difficult to tell you how to fix
this, but it could be as simple as replacing Dim o as Object with Dim o
as New Object, or by passing the value with ByVal if you're not
changing the value (or use a function if you need to change the value).
Warning 9 Type of parameter 'e' is not CLS-compliant.

I believe e is sort of a reserved parameter of the Type
System.EventArgs so using it as a different type may raise this warning
(just a guess)
The reason I want to separate listing of error and warning is that I can
quickly address the errors first during developement

If you open the error list tab, right below the title bar are three
toggle buttons:
{} Error, {} Warning, and {} Messages. Clicking on these will toggle
them on and off. However, you should always try to resolve any warning
messages that you can.

Hope that helps,

Seth Rowe
 
thx very much.

I still don't get it. the method Private Sub openMI_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles openMI.Click
Dim od As New OpenDialog()

Dim myDialogResult As DialogResult = od.ShowDialog(Me)
If myDialogResult = DialogResult.OK Then ' warning for
DialogResult.OK
ShowUrl(od.PathOrUrl)
End If
End Sub
I thought
DialogResult.OK is sort of constant (property, probably shared). I
actually tested the menu item and it did open a dialog for accepting an
valid URL and get ShowUrl() to navigate the browser to that successfully

So the warning is somewhat moot
 
If you have access to the source code then you could remove the Shared
keyword from the constant if you wanted, but like you said it doesn't
seem to matter. - I am obcessive compulsive when it comes to warning
messages : )

Thanks,

Seth Rowe
 
I usually would like to take care of the warnings too. as for
DialogResult.OK being shared I have no control as it was part of the
framework. I looked into the help before but could not figure out a
solution. As it turned out it was bogus warning.

The only thing I am serious concerned about is the one related to warning
#12, and the olecmd saveas function

' save a document into file specified by filespec string
Public Sub saveAs(ByVal strFileSpec As String)
Dim doOpt As SHDocVw.OLECMDEXECOPT
doOpt = SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER

MsgBox("SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER=" &
vbCrLf & SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
MsgBoxStyle.Information, "SaveAs @debug")
Dim o As New Object()
Try
webBrowser.ExecWB(SHDocVw.OLECMDID.OLECMDID_SAVEAS, doOpt,
CType(strFileSpec, Object), o)
Catch
Throw (New Exception(Err.GetException().Message))
End Try
End Sub ' saveAs

It does saveas but with prompt which I dont want.


Aha, I fount the discrepancies. supposedly
public struct OLECMDTEXT
{
public uint cmdtextf;
public uint cwActual;
public uint cwBuf;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=100)]public char rgwz;
}
// I have trouble translating the above to vb
// tried
// <MarshalAs(UnmanagedType.ByValTStr,SizeConst=100)>public char rgwz;
// also
// <MarshalAs(UnmanagedType.ByValTStr,SizeConst As Integer =100)>public char
rgwz;
//
[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
public uint cmdID;
public uint cmdf;
}


But the example source code has Long in place of unit
<StructLayout(LayoutKind.Sequential)> _
Public Structure OLECMDTEXT
Public cmdtextf As UInt32
Public cwActual As UInt32
Public cwBuf As UInt32
Public rgwz As Char
End Structure

<StructLayout(LayoutKind.Sequential)> _
Public Structure OLECMD
Public cmdID As Long ' <== should be Uint32
Public cmdf As UInt64 ' <== should be unit32 according to KB329014
End Structure


despite the changes, I still have the prompt popping up on me
 
You've got me on that one. Maybe one of the gurus can help.

Good Luck!

Seth Rowe
I usually would like to take care of the warnings too. as for
DialogResult.OK being shared I have no control as it was part of the
framework. I looked into the help before but could not figure out a
solution. As it turned out it was bogus warning.

The only thing I am serious concerned about is the one related to warning
#12, and the olecmd saveas function

' save a document into file specified by filespec string
Public Sub saveAs(ByVal strFileSpec As String)
Dim doOpt As SHDocVw.OLECMDEXECOPT
doOpt = SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER

MsgBox("SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER=" &
vbCrLf & SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
MsgBoxStyle.Information, "SaveAs @debug")
Dim o As New Object()
Try
webBrowser.ExecWB(SHDocVw.OLECMDID.OLECMDID_SAVEAS, doOpt,
CType(strFileSpec, Object), o)
Catch
Throw (New Exception(Err.GetException().Message))
End Try
End Sub ' saveAs

It does saveas but with prompt which I dont want.


Aha, I fount the discrepancies. supposedly
public struct OLECMDTEXT
{
public uint cmdtextf;
public uint cwActual;
public uint cwBuf;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=100)]public char rgwz;
}
// I have trouble translating the above to vb
// tried
// <MarshalAs(UnmanagedType.ByValTStr,SizeConst=100)>public char rgwz;
// also
// <MarshalAs(UnmanagedType.ByValTStr,SizeConst As Integer =100)>public char
rgwz;
//
[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
public uint cmdID;
public uint cmdf;
}


But the example source code has Long in place of unit
<StructLayout(LayoutKind.Sequential)> _
Public Structure OLECMDTEXT
Public cmdtextf As UInt32
Public cwActual As UInt32
Public cwBuf As UInt32
Public rgwz As Char
End Structure

<StructLayout(LayoutKind.Sequential)> _
Public Structure OLECMD
Public cmdID As Long ' <== should be Uint32
Public cmdf As UInt64 ' <== should be unit32 according to KB329014
End Structure


despite the changes, I still have the prompt popping up on me
rowe_newsgroups said:
If you have access to the source code then you could remove the Shared
keyword from the constant if you wanted, but like you said it doesn't
seem to matter. - I am obcessive compulsive when it comes to warning
messages : )

Thanks,

Seth Rowe
 
Back
Top