Joseph
Joseph

Reputation: 93

Cannot access class in ASP.NET

I have created an ASPX web application, that I have compiled and works fine when running through Visual Studio on my local PC.

However, on the server I get the error message

*Compiler Error Message: BC30451: 'epoDB' is not declared. It may be inaccessible due to its protection level. *

epoDB is a name of a class that I have that contains several methods. I am not using a "Code-Behind" file, this is just a separate file epoDB.vb. When I publish this website it is creating a 60 KB DLL in the BIN folder. I have checked the webConfig and it is set properly to allow all assemblies.

Here is some code: (ASPX PAGE)

<% @ Import Namespace="epoApprover" 
If Not Action = "X" Then Decrypted = epoDB.AES_Decrypt(RawString)
%>

The first time it hits this method AES_Decrypt, I am told epoDB is not declared.

Here is the epoDB.vb

Public Class epoDB    
    Public Shared Function AES_Decrypt(ByVal input As String) As String
       'decryption method
        Return decrypted
    End Function
End Class

This EpoDB.vb is a separate file. I have a few classes and it compiles into a 60KB epoApprover.dll , yet I don't seem to be able to access any of these classes.
Using .NET 4.0 / IIS6 / Windows 2003 64-bit.

I have tried many things, such as putting these classes in App_Code, leaving them on the root, yet nothing seems to work -- I think I am missing a fundamental. Any advice?

Upvotes: 1

Views: 931

Answers (2)

Joseph
Joseph

Reputation: 93

Turns out IIS was just setup as a web folder. Once I converted it to a web application it was able to find everything. I knew it was something fundamental!

Upvotes: 1

EdSF
EdSF

Reputation: 12351

You are mixing your code with a Page declaration.

<% @ Import Namespace="epoApprover" 
If Not Action = "X" Then Decrypted = epoDB.AES_Decrypt(RawString)
%>

So:

<%@ Import Namespace="epoApprover"%>

<%     
    If foo Then
       ....
    End If    
%>

Though for inline style (not CodeFile nor CodeBehind) code is in:

<script runat="server">

   `Sub procs, Functions, etc.

</script>

Your .vb file should be in App_Code. Unsure how your code above worked on your local PC.

Hth...

Upvotes: 0

Related Questions