35

I have an assembly comprised of several useful little utilities. Within that I have a module Containing a simple Public Function.

Module FishTrackerConfigurations

Public Function GetValueOfUseProductId As Boolean
    Return VtlGetUseProductId 'A simple private routine in the same module
End Function
End Module

When I call this function from another project (in which this assembly is referenced I get the following error.

Error   BC30390 'FishTrackerConfigurations.Public Function GetValueOfUseProductId() As Boolean' is not accessible in this context because it is 'Public'.   

The function is being called from within my projects Application.Xaml.VB file, specifically in the Protected Overrides Sub OnStartup(e As StartupEventArgs) routine.

I'd like to know why this happens.

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
Dom Sinclair
  • 2,458
  • 1
  • 30
  • 47

2 Answers2

53

Although the method is Public, the Module (by default) is not.

You need to specify this explicitly:

Public Module FishTrackerConfigurations
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
  • 4
    Thank you Matt, I'd always assumed Modules were public by default, I'll take that as today's new lesson learnt. You'll have to wait a short while before I can accept it! – Dom Sinclair Apr 19 '16 at 08:49
1

Sorry, no other way to thank Matt Wilko for the answer - since i can't neither comment nor upvote due to a lack of reputation - but i never expected to see something like "Function is not accessible in this context because it is 'Public'",

and i was like

throw new COMException("wait - what?!", HRESULT.E_UNEXPECTED)
KH-KH
  • 11
  • 2