错误的功能约束? [英] Wrong function bound?

查看:49
本文介绍了错误的功能约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好 - 我有一个VB.NET项目(框架版本1.1),其中我使用

函数InStr,格式如下:

Public Function InStr (ByVal String1 As String,ByVal String2 As String,

可选ByVal比较为Microsoft.VisualBasic.CompareMethod = 0)As

整数


(这是Intellisense提示的),而不是形式:

公共函数InStr(ByVal Start As Integer,ByVal String1 As String,ByVal

String2 As String ,可选ByVal比较为

Microsoft.VisualBasic.CompareMethod = 0)作为整数


请注意,使用的表单省略了可选的Start参数。 (Intellisense

不会提示包含Start参数,即使是逗号后面的null跟随

;而且Microsoft.VisualBasic.dll文件都是这两种形式。)但是,我有
有一个用户(只有一个报告成千上万),谁得到一个例外

对话,错误信息包括:

系统.ArgumentException:参数''Start''必须大于或等于零。


at Microsoft.VisualBasic.Strings.InStr(Int32 Start,String String1,

String String2,CompareMethod比较)

在Scenery_Align.mainForm.extractPath(字符串rawPath)



在Scenery_Align.mainForm.findOpenWithApp(String appName)


在Scenery_Align.mainForm.ButtonOpen_Click(对象发件人,EventArgs e)


....这两条红线似乎表示调用了错误版本的

函数。我有很多安装,但事实并非如此,

他们工作得很好。他安装了一个版本的.NET框架,它比我的更早,但是我让他重新安装了最新版本,所以他的

Microsoft.VisualBasic.dll是版本v7.10.6001.4,与我的相同。


任何人都知道为什么会这样,以及我能做些什么才能让它正常工作

在所有情况下?


谢谢 - 迪克比克斯勒

Hello - I have a project in VB.NET (framework version 1.1), in which I use
the function InStr in the following form:
Public Function InStr(ByVal String1 As String, ByVal String2 As String,
Optional ByVal Compare As Microsoft.VisualBasic.CompareMethod = 0) As
Integer

(which is what Intellisense prompts), rather than the form:
Public Function InStr(ByVal Start As Integer, ByVal String1 As String, ByVal
String2 As String, Optional ByVal Compare As
Microsoft.VisualBasic.CompareMethod = 0) As Integer

Note that the form used omits the optional Start parameter. (Intellisense
does not prompt for inclusion of the Start param, even for a null followed
by a comma; and Microsoft.VisualBasic.dll documents both forms.) However, I
have a user (only one reported out of thousands), who get an exception
dialogue, with the error message including:
System.ArgumentException: Argument ''Start'' must be greater or equal to zero.

at Microsoft.VisualBasic.Strings.InStr(Int32 Start, String String1,
String String2, CompareMethod Compare)

at Scenery_Align.mainForm.extractPath(String rawPath)

at Scenery_Align.mainForm.findOpenWithApp(String appName)

at Scenery_Align.mainForm.ButtonOpen_Click(Object sender, EventArgs e)

....the two red lines would seem to indicate that the wrong version of the
function is called. I have many installations where this is not the case,
they work just fine. He had a version of the .NET framework installed that
was earlier than mine, but I had him re-install the latest so his
Microsoft.VisualBasic.dll is version v7.10.6001.4, same as mine.

Anyone know why this would occur, and what I can do to make it work properly
in all cases?

Thanks -- Dick Bixler


推荐答案

理查德,

不确定在你的问题上建议什么。我怀疑你正在传递一个

无效的起始位置,如表达式所示。引起

问题的用户输入的值可能与其他人略有不同,

导致问题。


|在Scenery_Align.mainForm.extractPath(String rawPath)

extractPath告诉我你正在解析文件路径。我会建议而不是编写你自己的例程来解析文件路径,你需要使用System.IO.Path的方法来提取路径的各个部分。 。


希望这有帮助

Jay


" Richard Bixler" <是ne ****** @ earthlink.net>在留言中写道

新闻:哦************** @ TK2MSFTNGP11.phx.gbl ...

|您好 - 我在VB.NET(框架版本1.1)中有一个项目,我在其中使用

|函数InStr的形式如下:

|公共函数InStr(ByVal String1 As String,ByVal String2 As String,

|可选ByVal比较为Microsoft.VisualBasic.CompareMethod = 0)As

|整数

|

| (这是Intellisense提示的),而不是形式:

|公共函数InStr(ByVal Start As Integer,ByVal String1 As String,

ByVal

| String2 As String,可选ByVal比较为

| Microsoft .VisualBasic.CompareMethod = 0)作为整数

|

|请注意,使用的表单省略了可选的Start参数。 (Intellisense

|不会提示包含Start参数,即使对于空白跟随

|由逗号;以及Microsoft.VisualBasic.dll文档两种形式。)但是,



|有一个用户(只有一个报告成千上万),谁得到一个例外

|对话,错误信息包括:

| System.ArgumentException:参数''Start''必须大于或等于

零。

|

|在Microsoft.VisualBasic.Strings.InStr(Int32 Start,String String1,

| String String2,CompareMethod Compare)

|

|在Scenery_Align.mainForm.extractPath(String rawPath)

|

|在Scenery_Align.mainForm.findOpenWithApp(String appName)

|

|在Scenery_Align.mainForm.ButtonOpen_Click(Object sender,EventArgs e)

|

| ......两条红线似乎表明错误的版本是

|函数被调用。我有很多安装,但事实并非如此,

|他们工作得很好。他安装了一个.NET框架版本

|比我早,但我让他重新安装最新的所以他的

| Microsoft.VisualBasic.dll是版本v7.10.6001.4,与我的版本相同。

|

|任何人都知道为什么会这样,以及我能做些什么来使它工作

正确

|在所有情况下?

|

|谢谢 - 迪克比克斯勒

|

|

|

|
Richard,
Not sure what to suggest on your problem. I suspect you are passing in an
invalid starting position as the expression states. The user causing the
problem may be entering the value slightly differently then the others,
causing a problem.

| at Scenery_Align.mainForm.extractPath(String rawPath)
extractPath suggests to me that you are parsing a file path. I would
recommend rather then write your own routines to parse a file path, that you
use the methods of System.IO.Path to extract the various parts of a path.

Hope this helps
Jay

"Richard Bixler" <ne******@earthlink.net> wrote in message
news:Oh**************@TK2MSFTNGP11.phx.gbl...
| Hello - I have a project in VB.NET (framework version 1.1), in which I use
| the function InStr in the following form:
| Public Function InStr(ByVal String1 As String, ByVal String2 As String,
| Optional ByVal Compare As Microsoft.VisualBasic.CompareMethod = 0) As
| Integer
|
| (which is what Intellisense prompts), rather than the form:
| Public Function InStr(ByVal Start As Integer, ByVal String1 As String,
ByVal
| String2 As String, Optional ByVal Compare As
| Microsoft.VisualBasic.CompareMethod = 0) As Integer
|
| Note that the form used omits the optional Start parameter. (Intellisense
| does not prompt for inclusion of the Start param, even for a null followed
| by a comma; and Microsoft.VisualBasic.dll documents both forms.) However,
I
| have a user (only one reported out of thousands), who get an exception
| dialogue, with the error message including:
| System.ArgumentException: Argument ''Start'' must be greater or equal to
zero.
|
| at Microsoft.VisualBasic.Strings.InStr(Int32 Start, String String1,
| String String2, CompareMethod Compare)
|
| at Scenery_Align.mainForm.extractPath(String rawPath)
|
| at Scenery_Align.mainForm.findOpenWithApp(String appName)
|
| at Scenery_Align.mainForm.ButtonOpen_Click(Object sender, EventArgs e)
|
| ...the two red lines would seem to indicate that the wrong version of the
| function is called. I have many installations where this is not the case,
| they work just fine. He had a version of the .NET framework installed that
| was earlier than mine, but I had him re-install the latest so his
| Microsoft.VisualBasic.dll is version v7.10.6001.4, same as mine.
|
| Anyone know why this would occur, and what I can do to make it work
properly
| in all cases?
|
| Thanks -- Dick Bixler
|
|
|
|

< br>

2005-09-04,Richard Bixler< ne ****** @ earthlink.net>写道:
On 2005-09-04, Richard Bixler <ne******@earthlink.net> wrote:
你好 - 我在VB.NET(框架版本1.1)中有一个项目,其中我使用以下形式的函数InStr:
Public Function InStr( ByVal String1 As String,ByVal String2 As String,
可选ByVal比较为Microsoft.VisualBasic.CompareMethod = 0)作为
整数
Hello - I have a project in VB.NET (framework version 1.1), in which I use
the function InStr in the following form:
Public Function InStr(ByVal String1 As String, ByVal String2 As String,
Optional ByVal Compare As Microsoft.VisualBasic.CompareMethod = 0) As
Integer




为什么要穿你发布了导致错误的确切代码行吗?


同样周杰伦对IO.Path说的话。


另外,如果单个用户真正获得了超载功能,那么

可能意味着你有严格的选项权限。使用Option strict,始终在编译时选择

重载。可能是这样吗?



Why don''t you post the exact line of code that is getting the error?

Ditto what Jay said about IO.Path.

Also, if a single user really is getting the overloadeded function, that
probably means you have option strict off. With Option strict, the
overload is always chosen at compile time. Could that be so?


你好,谢谢。


首先,函数标题后跟barfs:


私有函数extractPath(ByVal rawPath As String)字符串


....(删除前面的字符,包括最左边的引号)


Barfs - >如果是InStr(rawPath,Chr(37),

Microsoft.VisualBasic.CompareMethod.Text)> 0然后_


rawPath = Trim(Microsoft.VisualBasic.Left(rawPath,InStr(rawPath,Chr(37),

Microsoft.VisualBasic.CompareMethod。文本) - 1))


变量rawPath从
返回
HKEY_LOCAL_MACHINE \ SOFTWARE \Classes \Applications\w ordpad.exe \ shell \ openn \命令,

,其值为 ;%ProgramFiles%\ Windows NT\Accessories \ WORDPAD.EXE" "%1"

包括引号作为字符串的一部分。我将这个转换为字符串

传递给Microsoft.VisualBasic.Shell,表格最终将是

C:\ Programr Files \ Windows NT\Accessories\WORDPAD.EXE

D:\ PROGRA~1 \ MICROS~1 \ FLIGHT~1 \\\cenery.cfg


你对选项严格是正确的。我将不得不修改一些隐含的

转换以将其打开...我应该这样做(并且会),但是需要快速回复

对于用户来说,在他的特定安装上执行时选择适当的过载是否会有所不同?


再次感谢 - Dick Bixler

" dfoster" < DF ***** @ woofix.local.dom>在消息中写道

news:sl ******************** @ localhost.localdomain。 ..
Hello, and thanks.

First, function header followed by line that barfs:

Private Function extractPath(ByVal rawPath As String) As String

.... (removes preceding chars including a leftmost quote mark)

Barfs--> If InStr(rawPath, Chr(37),
Microsoft.VisualBasic.CompareMethod.Text) > 0 Then _

rawPath = Trim(Microsoft.VisualBasic.Left(rawPath, InStr(rawPath, Chr(37),
Microsoft.VisualBasic.CompareMethod.Text) - 1))

The variable "rawPath" is returned from
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\w ordpad.exe\shell\open\command,
and its value is "%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE" "%1"
including the quotes as part of the string. I''m converting this to a string
to pass to pass to Microsoft.VisualBasic.Shell, the form will ultimately be
C:\Program Files\Windows NT\Accessories\WORDPAD.EXE
D:\PROGRA~1\MICROS~1\FLIGHT~1\scenery.cfg

You''re right about option strict. I''ll have to fix up some implicit
conversions to turn it on... I should do that (and will), but in the
interest of responding quickly to the user, will that make a difference in
choosing the proper overload when executed on his specific installation?

Thanks again -- Dick Bixler

"dfoster" <df*****@woofix.local.dom> wrote in message
news:sl********************@localhost.localdomain. ..
2005-09-04,Richard Bixler< ne ****** @ earthlink.net>写道:
On 2005-09-04, Richard Bixler <ne******@earthlink.net> wrote:
你好 - 我在VB.NET(框架版本1.1)中有一个项目,其中我使用
函数InStr,格式如下:
公共函数InStr(ByVal String1 As String,ByVal String2 As String,
可选ByVal比较为Microsoft.VisualBasic.CompareMethod = 0)作为
整数
Hello - I have a project in VB.NET (framework version 1.1), in which I
use
the function InStr in the following form:
Public Function InStr(ByVal String1 As String, ByVal String2 As String,
Optional ByVal Compare As Microsoft.VisualBasic.CompareMethod = 0) As
Integer



为什么要穿你发布了错误的确切代码行吗?

但是杰伊对IO.Path说了什么。

另外,如果单个用户真正得到了overloadeded功能,
可能意味着你有严格的选项。使用Option strict,始终在编译时选择
重载。可能是这样吗?



Why don''t you post the exact line of code that is getting the error?

Ditto what Jay said about IO.Path.

Also, if a single user really is getting the overloadeded function, that
probably means you have option strict off. With Option strict, the
overload is always chosen at compile time. Could that be so?



这篇关于错误的功能约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆