467,168 Members | 1,027 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,168 developers. It's quick & easy.

Intellisense, public modules, and public methods

I'm working in VB.Net, using Visual Studio 2003.

I have a project, let's call it Foo, that contains common methods, forms,
and objects I use in other projects. It compiles as Foo.dll, which I then
reference from the project that needs it.

Let's say I have a method, Bar, that I want to access from another project.
If I add a public module Methods to Foo, and add a public method Bar to
Methods, I can call it from my other project a couple of different ways, and
intellisense acts differently.

This works, but with no intellisense:
Foo.Bar

This works:
Foo.Methods (shows in intellisense)
and then:
Foo.Methods.Bar (shows in intellisense)

If, INSTEAD, I create a public class IO in Foo, and a public shared method
Bar in IO, I can call it like so (without instantiating a copy of the IO
class):

Foo.Bar (doesn't work)
Foo.IO.Bar (works, and shows in intellisense)

However, Microsoft, with their awesome powers, has a Namespace
Microsoft.VisualBasic, with a public module Strings, and a public method
UCase.

This works, even if I don't have Microsoft.VisualBasic imported:

UCase("string") (shows in intellisense)
Microsoft.VisualBasic.UCase("string") (shows in intellisense)
Microsoft.VisualBasic.Strings.UCase("string") (shows in intellisense)

I guess what I want is to have a Foo.dll, with a public module or class,
with the public method Bar, and be able to do this:

Foo.Bar

WITH intellisense. Microsoft can do it, why can't I? I appreciate any
assistance.
--
Christopher W. Douglas
SRS Technologies, Inc.
christopher (dot) douglas (at) srs (dot) com
Jul 21 '05 #1
  • viewed: 1859
Share:
1 Reply

Christopher W. Douglas wrote:
Let's say I have a method, Bar, that I want to access from another project. If I add a public module Methods to Foo, and add a public method Bar to Methods, I can call it from my other project a couple of different ways, and intellisense acts differently.

This works, but with no intellisense:
Foo.Bar
I wouldn't expect that to work because Bar is not a member of Foo but
of Methods.

This works:
Foo.Methods (shows in intellisense)
and then:
Foo.Methods.Bar (shows in intellisense)
That is the expected behavior

If, INSTEAD, I create a public class IO in Foo, and a public shared method Bar in IO, I can call it like so (without instantiating a copy of the IO class):

Foo.Bar (doesn't work)
Again, since Bar is not a member of Foo but of IO, I would not expect
this to work.
Foo.IO.Bar (works, and shows in intellisense)

This is the behavior I would expect.
However, Microsoft, with their awesome powers, has a Namespace
Microsoft.VisualBasic, with a public module Strings, and a public method UCase.

This works, even if I don't have Microsoft.VisualBasic imported:

UCase("string") (shows in intellisense)
Did you check your project properties to see if the VisualBasic
namespace was imported by default?
Microsoft.VisualBasic.UCase("string") (shows in intellisense)
Hmmm... I'm not sure how this works. It makes no sense. I checked
the IL and it seems to map to the function in the Strings namespace.
The only UCase I can find is Microsoft.VisualBasic.Strings.UCase. I'm
not sure how MS is pulling of this bit of wizardry. Maybe someone who
knows more about the internals of .Net can shed some light?
Microsoft.VisualBasic.Strings.UCase("string") (shows in intellisense)


Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Frank Jona | last post: by
3 posts views Thread by thdevdex | last post: by
2 posts views Thread by Don | last post: by
1 post views Thread by Vera | last post: by
1 post views Thread by Christopher W. Douglas | last post: by
1 post views Thread by Kimmo Laine | last post: by
5 posts views Thread by wal | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.