类型'TypeName'没有构造函数 [英] Type 'TypeName' has no constructors

查看:79
本文介绍了类型'TypeName'没有构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有人可以提供帮助,请!这让我发疯了。


我有几个级别的用户控件层次结构,用于

UserControl(windows)。

位于顶层的类具有以下构造函数(由VS.NET生成



Public Sub New()

MyBase.New()


''Windows窗体设计器需要此调用。

InitializeComponent()

''在InitializeComponent()调用后添加任何初始化


结束子


有时(大约一半的时间),当我重新编译我的解决方案(

包含一个带有这个类的项目,以及一个带有表单测试器的项目,试图用这个用户控件输出
),我得到了我在主题中输入的错误这个帖子。


现在,很明显,这个类有一个构造函数。

如果我通过删除单词''Public'来更改代码,并且重新编译一切

很棒。


下次我来ed重新编译,我再次收到此错误。在这种情况下,我只是将
放回公共这个词,并重新编译 - 一切都很好。


所以我花了一半我的时间删除''公共'然后再加入 - 只需

让编译器改变主意。


现在,它没有'' t一直这样做。有时它会重新编译好。


我已经检查了项目构建顺序 - 并且首先编译了带有用户控件的项目




我试过手动编译第一个项目 - 然后是第二个项目。并且

第二个总是失败,因为它认为没有可用的构造函数

用户控件。在此之前,我带走或删除构造函数中的''Public''

关键字 - 在这种情况下它的罚款。


这是一些荒谬的VB编译问题?一些VS.NET的bug。我能做什么吗?b $ b做些什么呢?


谢谢

解决方案

如果你没有把一个存取器放在那里它不是默认给朋友吗?在

这个案例中你的项目B(第二次编译)是否需要在同一个

名称空间中才能使它工作?

a构造函数可以使用它。


如果我错了,有人会纠正我。

" Marina" <所以***** @ nospam.com>写在消息

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

如果有人可以求助于此!这让我发疯了。

我有一个用户控件层次结构,深层次为
UserControl(windows)派生。

顶层的类level,有以下构造函数
(由VS.NET生成)
Public Sub New()
MyBase.New()

''此调用是必需的Windows窗体设计器。
InitializeComponent()
''在InitializeComponent()调用后添加任何初始化

End Sub

有时(大约一半)当我重新编译我的解决方案(其中包含一个带有这个类的项目,以及一个带有表单测试器的项目
试用这个用户控件)时,我得到了我在这个主题中的错误发布。

现在,显然,这个类有一个构造函数。
如果我通过删除单词''Public'来更改代码,并重新编译
一切都很棒。

下次我需要重新编译时,我再次收到此错误。在这种情况下,I
只是将公共这个词重新插入,并重新编译 - 一切都很好。

所以我花了一半的时间来删除''公共'和然后将它添加回 -
只是为了让编译器改变它的想法。

现在,它并不是一直这样做的。有时它会重新编译好。

我检查了项目构建顺序 - 并且首先编译了带有用户
控件的项目。

我已经尝试手动编译第一个项目 - 然后是第二个项目。并且第二个总是失败,因为它认为没有可用于用户控件的构造函数
。在那之前,我从构造函数中删除或删除''Public''
关键字 - 在这种情况下它很好。

这是一些荒谬的VB编译器问题吗?一些VS.NET的bug。我能用b $ b做什么吗?

谢谢



我不认为你仔细阅读我的帖子,但只是略读一些关键的

字。


构造函数被公开。这导致了一个错误。带走

''公共'然后编译好。


下次我做了一个更改,它不会再编译。所以我会把

''公共''重新插入。然后它又恢复了。


重点是,我一直需要添加和删除公共一词

每个其他更改以便让项目编译。


事实上,我认为默认为构造函数是''公共',否则

取''公共'',永远不会编译测试器应用程序,因为

那么它绝对不会有构造函数。


所以问题是,为什么编译器不断抱怨

没有找到构造函数,让我放置并删除单词''公共'

每隔一个编译时间,以使其工作?


注意:可能有其他方法可以使编译器工作

除了公共之外的其他技巧,我不知道。我刚刚找到一个简单的。


CJ Taylor < [cege] at [tavayn] dit commmmm>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP11.phx.gbl ...

如果你不要把一个存取器放在那里它不是默认给朋友吗?在哪种情况下你的项目B(第二次编译)不需要在同一个
命名空间中才能使它工作?

因此你的构造函数必须是声明公开或它不认为
构造函数可以使用它。

有人纠正我,如果我错了。

" ;匡" <所以***** @ nospam.com>在消息中写道
新闻:uz ************** @ TK2MSFTNGP11.phx.gbl ...

如果有人可以提供帮助,请!这让我发疯了。

我有一个用户控件层次结构,深层次为
UserControl(windows)派生。

顶层的类level,具有以下构造函数


(由VS.NET生成


Public Sub New()
MyBase.New()

''Windows窗体设计器需要此调用。
InitializeComponent()
''在InitializeComponent()调用后添加任何初始化

End Sub

有时(大约一半的时间),当我重新编译我的解决方案时(其中包含一个带有这个类的项目,一个带有表单测试器的项目


尝试< blockquote class =post_quotes> out this user control),我收到了我在这个
帖子主题中输入的错误。
现在,显然,这个类有一个构造函数。
如果我通过删除单词''Public'来更改代码,并重新编译


ev erything

很棒。

下次我需要重新编译时,我再次收到此错误。在这种情况下,我


只是

将公共这个词放回去,并重新编译 - 一切都很好。

所以我花了一半时间删除''Public'然后将其添加回 -


只是

让编译器改变主意。

我检查了项目构建顺序 - 并且首先编译了带有用户


control

的项目。

我试过手动编译第一个项目 - 然后是第二个项目。
第二个总是失败,因为它认为用户控件没有构造函数


。在那之前,我从构造函数中删除或删除''Public''
关键字 - 在这种情况下它很好。

这是一些荒谬的VB编译器问题吗?一些VS.NET的bug。我


可以

做什么吗?

谢谢




嗨Marina,


我不知道这个问题,但是你已经尝试了新的

应用程序,只有最需要的东西。


只是一个想法。


Cor


Hi, if anyone can help on this, please! This is driving me crazy.

I have a user control hierarchy several levels deep that derive for
UserControl (windows).

The class that is at the top level, has the following constructor (generated
by VS.NET)
Public Sub New()
MyBase.New()

''This call is required by the Windows Form Designer.
InitializeComponent()
''Add any initialization after the InitializeComponent() call

End Sub

Sometimes (about half the time), when I recompile my solution (which
contains a project with this class, and a project with a form tester trying
out this user control), I get the error I put in the subject of this post.

Now, clearly, this class has a constructor.
If I change the code by removing the word ''Public'', and recompile everything
is great.

Next time I need to recompile, I get this error again. In this case, I just
put the word ''Public'' back in, and recompile - all is well again.

So I spend half my time removing ''Public'' and then adding it back in - just
to get the compiler to change its mind.

Now, it doesn''t do this all the time. Sometimes it recompiles OK.

I''ve checked the project build order - and the project with the user control
is compiled first.

I''ve tried manually compiling the first project - and then the second. And
the second always fails, because it thinks there is no constructor available
for the user control. Until that is, I take away or remove the ''Public''
keyword off of the constructor - in which case its fine.

Is this some ridiculous VB compiler problem? Some VS.NET bug. Anything I can
do about it?

Thanks

解决方案

If you don''t put an accessor on there doesn''t it default it to Friend? In
which case doesn''t your project B (second compiled) need to be in the same
namespace in order for that to work?

So therefore you contructor must be declared public or it doesn''t think that
a constructor is avalible for it to use.

Someone correct me if I''m wrong.
"Marina" <so*****@nospam.com> wrote in message
news:uz**************@TK2MSFTNGP11.phx.gbl...

Hi, if anyone can help on this, please! This is driving me crazy.

I have a user control hierarchy several levels deep that derive for
UserControl (windows).

The class that is at the top level, has the following constructor (generated by VS.NET)
Public Sub New()
MyBase.New()

''This call is required by the Windows Form Designer.
InitializeComponent()
''Add any initialization after the InitializeComponent() call

End Sub

Sometimes (about half the time), when I recompile my solution (which
contains a project with this class, and a project with a form tester trying out this user control), I get the error I put in the subject of this post.

Now, clearly, this class has a constructor.
If I change the code by removing the word ''Public'', and recompile everything is great.

Next time I need to recompile, I get this error again. In this case, I just put the word ''Public'' back in, and recompile - all is well again.

So I spend half my time removing ''Public'' and then adding it back in - just to get the compiler to change its mind.

Now, it doesn''t do this all the time. Sometimes it recompiles OK.

I''ve checked the project build order - and the project with the user control is compiled first.

I''ve tried manually compiling the first project - and then the second. And
the second always fails, because it thinks there is no constructor available for the user control. Until that is, I take away or remove the ''Public''
keyword off of the constructor - in which case its fine.

Is this some ridiculous VB compiler problem? Some VS.NET bug. Anything I can do about it?

Thanks



I don''t think you carefully read my post, but just skimmed for some key
words.

The constructor was declared public. And that caused an error. Taking away
''Public'' would then compile fine.

Next time I made a change, it woudln''t compile again. So I would put the
''Public'' back in. Then it was fine again.

The point being, that I kept needing to add and remove the word ''Public''
every other change in order to get the project to compile.

In fact, I believe that the default for a constructor is ''Public'', else
taking ''Public'' away, would never have compiled the tester application, as
then it definitely would not have had a constructor.

So again, the question is, why is the compiler complaining constantly about
not finding a constructor, making me place and remove the word ''Public''
every other compile time, in order to make it work?

Note: There may be other ways that work in getting the compiler to work
other then this trick with ''Public'', I don''t know. I just found an easy one.

"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

If you don''t put an accessor on there doesn''t it default it to Friend? In
which case doesn''t your project B (second compiled) need to be in the same
namespace in order for that to work?

So therefore you contructor must be declared public or it doesn''t think that a constructor is avalible for it to use.

Someone correct me if I''m wrong.
"Marina" <so*****@nospam.com> wrote in message
news:uz**************@TK2MSFTNGP11.phx.gbl...

Hi, if anyone can help on this, please! This is driving me crazy.

I have a user control hierarchy several levels deep that derive for
UserControl (windows).

The class that is at the top level, has the following constructor


(generated

by VS.NET)
Public Sub New()
MyBase.New()

''This call is required by the Windows Form Designer.
InitializeComponent()
''Add any initialization after the InitializeComponent() call

End Sub

Sometimes (about half the time), when I recompile my solution (which
contains a project with this class, and a project with a form tester


trying

out this user control), I get the error I put in the subject of this post.
Now, clearly, this class has a constructor.
If I change the code by removing the word ''Public'', and recompile


everything

is great.

Next time I need to recompile, I get this error again. In this case, I


just

put the word ''Public'' back in, and recompile - all is well again.

So I spend half my time removing ''Public'' and then adding it back in -


just

to get the compiler to change its mind.

Now, it doesn''t do this all the time. Sometimes it recompiles OK.

I''ve checked the project build order - and the project with the user


control

is compiled first.

I''ve tried manually compiling the first project - and then the second. And the second always fails, because it thinks there is no constructor


available

for the user control. Until that is, I take away or remove the ''Public''
keyword off of the constructor - in which case its fine.

Is this some ridiculous VB compiler problem? Some VS.NET bug. Anything I


can

do about it?

Thanks




Hi Marina,

I do not know this problem, however did you try it already with a new
application and only the most needed things in it.

Just an idea.

Cor


这篇关于类型'TypeName'没有构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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