Reputation: 2183
I'm getting an error in .net when trying to declare a Public class on my code behind page.
Partial Class _Default
Inherits System.Web.UI.Page
Public someVariable as integer
Public someClass as className
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load [...]
The error I'm getting is BC30508: 'someClass' cannot expose type 'className' in namespace '<Default>' through class '_Default'.
The goal here is accessing the class properties in script blocks on the aspx page like this <%=someClass.classProperty%>
I'm not sure if I'm trying the right methods (I've tried several ways of declaring the public class) or if it can even be done... Thanks for taking a look at it.
Upvotes: 3
Views: 3092
Reputation: 2226
It's almost certainly the declaration of your "className" class. Try setting it to public.
Upvotes: 1
Reputation: 416049
Check the protection level of your className
type. Did you forget to mark it public?
That error message means you have something that is has restricted access, and you are trying to use it in a way that would allow access outside the restrictions. For example, if your className
type is internal
or a private
child class of _Default
, but you add a public member of that type as a property your assembly would expose a type as part of it's interface that is otherwise unusable.
Upvotes: 8
Reputation: 7240
Check the protection level of the _Default class. It might not be setup as a partial class and that will result in your protection level issue that you are seeing.
Upvotes: 0