Class not getting built

T

tshad

I have the following class in my VS 2008 project that has a namespace of
MyFunctions.

*********************************
Imports System
Imports System.Text.RegularExpressions

Namespace MyFunctions

Public Class BitHandling

'*----------------------------------------------------------*
'* Name : BitSet *
'*----------------------------------------------------------*
'* Purpose : Sets a given Bit in Number *
'*----------------------------------------------------------*
Public Shared Function BitSet(ByVal Number As Integer, _
ByVal Bit As Integer) As Long
If Bit = 31 Then
Number = &H80000000 Or Number
Else
Number = (2 ^ Bit) Or Number
End If
BitSet = Number
End Function

'*----------------------------------------------------------*
'* Name : BitClear *
'*----------------------------------------------------------*
'* Purpose : Clears a given Bit in Number *
'*----------------------------------------------------------*
Public Shared Function BitClear(ByVal Number As Integer, _
ByVal Bit As Integer) As Long
If Bit = 31 Then
Number = &H7FFFFFFF And Number
Else
Number = ((2 ^ Bit) Xor &HFFFFFFFF) And Number
End If

BitClear = Number
End Function

'*----------------------------------------------------------*
'* Name : BitIsSet *
'*----------------------------------------------------------*
'* Purpose : Test if bit 0 to bit 31 is set *
'*----------------------------------------------------------*
Public Shared Function BitIsSet(ByVal Number As Integer, _
ByVal Bit As Integer) As Boolean
BitIsSet = False

If Bit = 31 Then
If Number And &H80000000 Then BitIsSet = True
Else
If Number And (2 ^ Bit) Then BitIsSet = True
End If
End Function

End Class

Public Class Strings

'*----------------------------------------------------------*
'* Name : StripHtml *
'*----------------------------------------------------------*
'* Purpose :Strip HTML tags from Text *
'*----------------------------------------------------------*
Public Shared Function stripHTML(ByVal strHTML As String) As String
'Strips the HTML tags from strHTML

Dim strOutput As String
Dim objRegExp As New Regex("<(.|\n)+?>", RegexOptions.IgnoreCase)

'Replace all HTML tag matches with the empty string
strOutput = objRegExp.Replace(strHTML, "")

'Replace all < and > with &lt; and &gt;
strOutput = strOutput.Replace("<", "&lt;")
strOutput = strOutput.Replace(">", "&gt;")

stripHTML = strOutput 'Return the value of strOutput
End Function

End Class

End Namespace

**********************************

In my default.aspx.vb I have:

Imports MyFunctions

But I am getting an error:

*************************************************
Namespace or type specified in the project-level Imports 'MyFunctions'
doesn't contain any public member or cannot be found. Make sure the
namespace or the type is defined and contains at least one public member.
Make sure the alias name doesn't contain other aliases.
*************************************************

But the above, namespace does exist and has public members (all of which
give me errors in my code saying that they are not declared?

I tried putting this file in the root as well as the under a folder called
"Classes" as I had it in my 2003 project and I also tried putting it in the
App_Code folder. None of which worked.

What am I missing?

Thanks,

Tom
 
T

tshad

I need to find out why this is not compiling.

I can't go any further without it. I am getting "not defined" errors for
all the functions in this class.

This is just a class not an aspx.vb page. And it is included in the
project.

It is a very simple Web Site project with very little in it at this point.

It has the App_Code, Images, and CSS folders and default.aspx is in the
root.

I have put my BitHandling.vb in the root and in the App_Code folder and it
seems to ignore it.

Why is that?

Thanks,

Tom
 
T

tshad

I did try to run a makeBitHandling.bat file from the console and put the
..dll into a bin folder that I created which is how I did it in VS 2003.

vbc /t:library bitHandling.vb /r:system.dll
attrib ..\bin\bitHandling.dll -r
copy bitHandling.dll ..\bin\*.*

The .bat file wouldn't work correctly. It gave me the error:

'???vbc' is not recognized as an internal or external command,
operable program or batch file.

Not sure what the prefix characters are but if I copy the lines and paste
them into the console, it works fine and puts the .dll file into the bin
folder.

Now when I type in:

Imports MyFunctions

It recognizes it. When I type it "Imports ", Intellisense shows MyFunctions
in the list - so it does see it.

but all the functions: BitClear, BitSet and BitIsSet all show as undefined.
And you can see the class below where all the functions are private.

Why doesn't the program see them????

Thanks,

Tom
 
A

Anthony Jones

tshad said:
I have the following class in my VS 2008 project that has a namespace of
MyFunctions.

*********************************
Imports System
Imports System.Text.RegularExpressions

Namespace MyFunctions

Public Class BitHandling

'*----------------------------------------------------------*
'* Name : BitSet *
'*----------------------------------------------------------*
'* Purpose : Sets a given Bit in Number *
'*----------------------------------------------------------*
Public Shared Function BitSet(ByVal Number As Integer, _
ByVal Bit As Integer) As Long
If Bit = 31 Then
Number = &H80000000 Or Number
Else
Number = (2 ^ Bit) Or Number
End If
BitSet = Number
End Function

'*----------------------------------------------------------*
'* Name : BitClear *
'*----------------------------------------------------------*
'* Purpose : Clears a given Bit in Number *
'*----------------------------------------------------------*
Public Shared Function BitClear(ByVal Number As Integer, _
ByVal Bit As Integer) As Long
If Bit = 31 Then
Number = &H7FFFFFFF And Number
Else
Number = ((2 ^ Bit) Xor &HFFFFFFFF) And Number
End If

BitClear = Number
End Function

'*----------------------------------------------------------*
'* Name : BitIsSet *
'*----------------------------------------------------------*
'* Purpose : Test if bit 0 to bit 31 is set *
'*----------------------------------------------------------*
Public Shared Function BitIsSet(ByVal Number As Integer, _
ByVal Bit As Integer) As Boolean
BitIsSet = False

If Bit = 31 Then
If Number And &H80000000 Then BitIsSet = True
Else
If Number And (2 ^ Bit) Then BitIsSet = True
End If
End Function

End Class

Public Class Strings

'*----------------------------------------------------------*
'* Name : StripHtml *
'*----------------------------------------------------------*
'* Purpose :Strip HTML tags from Text *
'*----------------------------------------------------------*
Public Shared Function stripHTML(ByVal strHTML As String) As String
'Strips the HTML tags from strHTML

Dim strOutput As String
Dim objRegExp As New Regex("<(.|\n)+?>", RegexOptions.IgnoreCase)

'Replace all HTML tag matches with the empty string
strOutput = objRegExp.Replace(strHTML, "")

'Replace all < and > with &lt; and &gt;
strOutput = strOutput.Replace("<", "&lt;")
strOutput = strOutput.Replace(">", "&gt;")

stripHTML = strOutput 'Return the value of strOutput
End Function

End Class

End Namespace

**********************************

In my default.aspx.vb I have:

Imports MyFunctions

But I am getting an error:

*************************************************
Namespace or type specified in the project-level Imports 'MyFunctions'
doesn't contain any public member or cannot be found. Make sure the
namespace or the type is defined and contains at least one public member.
Make sure the alias name doesn't contain other aliases.
*************************************************

But the above, namespace does exist and has public members (all of which
give me errors in my code saying that they are not declared?

I tried putting this file in the root as well as the under a folder called
"Classes" as I had it in my 2003 project and I also tried putting it in
the App_Code folder. None of which worked.

What am I missing?

Try adding this attribute to the system.web/compilation element in your
web.config

defaultLanguage="VB"

Note your .vb file should be placed in the App_Code folder, remove it from
the root.
 
T

tshad

Anthony said:
Try adding this attribute to the system.web/compilation element in
your web.config

defaultLanguage="VB"

Note your .vb file should be placed in the App_Code folder, remove it
from the root.

I did that and it doesn't compile.

If I compile the program by hand and put the dll into the bin folder - it
works fine. All the errors that use the functions go away. When typing in
Imports - MyFunctions shows up fine in the list.

But if I delete the dll and put the same BitHandling.vb into the App_Code
folder - nothing happens and I get errors for all the BitHandling functions
and MyFunctions is now not in the Intellisense list when typing in Imports.

I also added this line into the system.web node of the web.config file:
<compilation defaultLanguage="VB" debug="true">

But that didn't help either.

Thanks,

Tom
 
T

tshad

tshad said:
I did that and it doesn't compile.

If I compile the program by hand and put the dll into the bin folder
- it works fine. All the errors that use the functions go away. When
typing in Imports - MyFunctions shows up fine in the list.

But if I delete the dll and put the same BitHandling.vb into the
App_Code folder - nothing happens and I get errors for all the
BitHandling functions and MyFunctions is now not in the Intellisense
list when typing in Imports.
I also added this line into the system.web node of the web.config
file: <compilation defaultLanguage="VB" debug="true">

But that didn't help either.

I was able to get this to work using the App_Code as was suggested and
adding the a few lines to the web.config file.

I was also able to get both my vb and cs files to compile (only in the web
site project but on in a Class Library) by setting up 2 folders in the
App_Code folder and pointing at the in the web.config file as suggested by
others.

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top