[VB.NET]: Extract functions into a separate class/namespace - How?

C

cha

Hi there,

I wonder what the best way would be to extract some basic functions
into a separate class/namespace and make them accessible for a
ASP.NET-Page (aspx) and a NET-WebService (asmx). Both files are written
in VB.NET

Is there a detailled description somewhere existing in the Internet of
how to do the extraction of basic funtions into a separate
class/namespace and use this new class/namespace then within a ASP.NET
and a NET-WebService file ?

Thank you very much for any help in advance,

Christian
 
S

Scott M.

This is very simple to do.

Just create a "Class Library" project and build your class with whatever
methods needed. Compile this project.

The assembly that you just created is now available to ANY kind of .NET
project (written in ANY .NET language) by simply making a reference to this
assembly from your project.

That's it.
 
C

cha

First of all, thanks for your help. This sounds to be rather easy...

However, if I have created a file called XMLHelper.vb like that

Namespace HWFHelper
Public Class XMLHelper
Public Function getReplacementAnd(ByVal text As String) As
String
....
End Function
End Class
End Namespace

The compiler has done it's job and I was able to add it to the .NET
onfiguration as a .NET assembly.

But how do I reference this new class/namespace within my asmx-File
using Notepad?

Imports HWFHelper

leads to an 'BC30466'-Error (Namespace or Typ 'HWFHelper' for import
'HWFHelper' not found).

So, what am I doing wrong here?

Regards,

Christian
 
S

Scott M.

You need to make a reference to an assembly before you can use it in any way
(i.e. an Imports statement).

I don't know what code you need to add since I use VS.NET. First of all,
place the assembly in your project's bin folder. You may try adding this:
<% @Assembly Src="myData.vb"%> to the .asmx file.
 
C

Cor Ligthert

Christian,

As you do it as Scott tells and make a DLL from it, than you can reference
to it as to any other DLL in your application.

This kind of notebook programming are often done in the newsgroup aspnet.

Maybe can you look self for the exact or maybe other solution in that
newsgroup.

Aspnet
news://msnews.microsoft.com/microsoft.public.dotnet.framework.aspnet

Web interface:
http://communities2.microsoft.com/c.../?dg=microsoft.public.dotnet.framework.aspnet

I hope this helps a little bit?

Cor
 
C

cha

Dear Scott,

thank you very much for your help.

The

<% @Assembly Src="myData.vb"%>

is exactly what I have been looking for.

Now everything works properly!

Regards,

Christian
 

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

Top