Hi Juan,
Thanks for your help. I have tried what you suggested and am getting
some errors. Here, first, are the contents of my .vb file:
---------------------------------------------
Imports System.Globaliz ation
Namespace ByteArray
Public Class ByteArray
Inherits System.Componen tModel.Componen t
#Region " Component Designer generated code "
Public Sub New(ByVal Container As
System.Componen tModel.IContain er)
MyClass.New()
'Required for Windows.Forms Class Composition Designer
support
Container.Add(M e)
End Sub
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeCompo nent()
'Add any initialization after the InitializeCompo nent()
call
End Sub
'Component overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub
'Required by the Component Designer
Private components As System.Componen tModel.IContain er
'NOTE: The following procedure is required by the Component
Designer
'It can be modified using the Component Designer.
'Do not modify it using the code editor.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
components = New System.Componen tModel.Containe r
End Sub
#End Region
Public Function CreateTypeByte( ByVal strInput As String) As
Byte()
Dim i As Integer
Dim arrChar As Char()
arrChar = strInput.ToChar Array()
Dim arrByte(arrChar .Length - 1) As Byte
For i = 0 To arrByte.Length - 1
arrByte(i) = Convert.ToByte( arrChar(i))
Next
Return arrByte
End Function
Public Function CreateTypeHex(B yVal strInput As String) As
Byte()
Dim i As Integer
Dim arrString As String()
arrString = strInput.Split( New Char() {"-"})
Dim arrByte(arrStri ng.Length - 1) As Byte
For i = 0 To arrByte.Length - 1
arrByte(i) = Byte.Parse(arrS tring(i),
NumberStyles.He xNumber)
Next
Return arrByte
End Function
End Class
End Namespace
---------------------------------------------
I then compile it using:
c:\WINNT\Micros oft.NET\Framewo rk\v1.1.4322\cs c.exe /target:library
/out:ByteArray.d ll /r:System.dll
C:\Inetpub\wwwr oot\testApp\Byt eArray.vb
I get a bunch of errors of four basic types:
-Preprocessor directive expected.
-Single Line Comment or End-of-Line expected.
-Newline in constant.
-A Namespace does not directly contain members such as fields or
methods.
Do you know why I am getting them. If I take out the system generated
code, the errors decrease, but I thought that the system generated code
was supposed to make my class more usuable. (Plus, I still get some of
the errors even without the system generated code.)
Thanks,
Ryan
Juan T. Llibre wrote:
re: How then would I reference this in a new Web Application
(or in the same web application for that matter?)
To reference that code in a new web Application, you'd have
to compile the code from the command-line, and reference
*that* assembly in your VS.NET project.
To compile a single source code file, use :
csc /t:library /out:utils.dll utils.cs
To compile all .cs files in a directory to utils.dll ,
use : csc /t:library /out:utils.dll *.cs
If you need to reference a .Net Framework assembly or assemblies,
add them, separated by slashes :
csc /t:library /r:system.dll /r:system.data.d ll /out:utils.dll *.cs
If you're using VB.NET instead of C#,
use vbc and source files ending in .vb
instead of using csc and source files ending in .cs.
The syntax is the same for vb and c#.
Once you have compiled your assembly, place it in the /bin
directory of your application, and import the Namespace :
<%@ Import Namespace="Byte Array" %>
If you're working strictly with VS.NET, compile your assembly
as described and add a reference to it in your VS.NET project.
That will allow you to use Intellisense and get your
assembly's properties, methods, etc. when coding.
Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
=============== =======
<ry************ @kp.org> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
I built and rebuilt the project and solution and get no skips and no
errors. Just a report of success...But then when I test my ASP page in
my browser, I get the message in the compiler output that my namespace
could not be found.
Any thoughts?
Ryan
Juan T. Llibre wrote: Did you compile it ?
Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
=============== =======
<ry************ @kp.org> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. . Hello,
I have code that I wish to use in many web applications. Basically
sort of stand utility stuff. So from Visual Studio Project I select
add a component and chose Component Class. Lets say I enter code at
the end of this question in to the code section.
How then would I reference this in a new Web Application (or in the
same web application for that matter?)
I have tried:
<%@ Import Namespace="Byte Array.ByteArray " %>
and
<%@ Import Namespace="Byte Array" %>
But when I run the page it just gives me a message that the Namespace
can't be found.
Thanks,
Ryan
------------CODE FOLLOWS-----------------------------
Imports System.Globaliz ation
Namespace ByteArray
Public Class ByteArray
Inherits System.Componen tModel.Componen t
|Component Designer generated code...|
Public Function CreateTypeByte( ByVal strInput As String) As
Byte()
Dim i As Integer
Dim arrChar As Char()
arrChar = strInput.ToChar Array()
Dim arrByte(arrChar .Length - 1) As Byte
For i = 0 To arrByte.Length - 1
arrByte(i) = Convert.ToByte( arrChar(i))
Next
Return arrByte
End Function
Public Function CreateTypeHex(B yVal strInput As String) As
Byte()
Dim i As Integer
Dim arrString As String()
arrString = strInput.Split( New Char() {"-"})
Dim arrByte(arrStri ng.Length - 1) As Byte
For i = 0 To arrByte.Length - 1
arrByte(i) = Byte.Parse(arrS tring(i),
NumberStyles.He xNumber)
Next
Return arrByte
End Function
End Class
End Namespace