Namespace - in ASP.NET and libraries

G

Guest

hello,

all my libraries (dll - .NET 1.1) have there own namespace which starts with
"mycompany....."

If i have now also own classes in the application - i want also to use the
same namespace - but i see that the i can not more access the my external
referenced libraries.

Is it not possible this - ore what must i do. I did not want to embed my
general libraries in the application (like encryption ....). The specific DAL
for the application i embed in the application - but i want to use as
namespace mycompany - name.

Also i want to have the flexibility to choose where to the code (external
dll or as internal class) and the best way is to have the same namespace.

any ideas - or recomandation?
 
K

Kevin Spencer

I'm not sure I understand the question. I too have several different
assemblies having namespaces that all begin with my company name, such as
DsiGlobal, DsiGlobal.Net, DsiGlobal.Imaging, etc., but they are in separate
assemblies, which must all be included in any project that employs more than
one of them. This is actually a good thing, as it doesn't necessitate
loading any code not needed by the present app. So, what exactly is the
problem?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
G

Guest

the problem apears in the case when in the main application i also have some
calsses with the same namespace (for example when in the asp.net application
i create classes with a explicit entry of Namespace mycompany.....

The same problem apears if i change the namespace of the asp.net application
to mycompany.myapplication

thanks
 
K

Kevin Spencer

What problem?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
G

Guest

The error message is:
C:\Inetpub\10.118.164.237_81\WebApp1\WebForm1.aspx.vb(33): Type
'MyCompany.FBLib1' is not defined.

i show the the steps to get reproduce error.



*in a ASP.Net application with the namespace WebApp1 there is a webform
"WebForm1.aspx"
In the webform there are to labels (Label1 and Label2) If i push the button
the following code is executed


Dim oExternalLib As New MyCompany.FBLib1
Label1.Text = oExternalLib.FBEcho("Hello")

Dim oInternalClass As MyCompany1.InternalTest.MyCompany_InternalClass
Label2.Text = oInternalClass.Test


All works ok.

The code for my internal class (in the asp,net application)
Namespace MyCompany.InternalTest
Public Class MyCompany_InternalClass
Public Function Test() As String
Return "InternalTest"
End Function
End Class
End Namespace


BUT - if i try to change the Namespace for the internalClass from MyCompany1
to MyCompany1 then i get the error



C:\Inetpub\10.118.164.237_81\WebApp1\WebForm1.aspx.vb(33): Type
'MyCompany.FBLib1' is not defined.

i hope you understand now my problem.
best regards
 
K

Kevin Spencer

BUT - if i try to change the Namespace for the internalClass from
MyCompany1
to MyCompany1 then i get the error



C:\Inetpub\10.118.164.237_81\WebApp1\WebForm1.aspx.vb(33): Type
'MyCompany.FBLib1' is not defined.

The error message indicates that your code is referencing the namespace
"MyCompany" whereas you have said that you renamed the namespace to
"MyCompany1."

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
G

Guest

Hello Kevin,

thank for your replies, but please read carefully - when the problem apears


!!! i changed only the namespace of the internalClass from

original

after this change error apears in the line
Dim oExternalLib As New MyCompany.FBLib1 '!!! ( visual studio could not
more reference the external dll !!!! - as soon the namespace has the same
name

'for the the external class (the dll - was not modified - it has the
namespace MyCompany - but is no more visible in the asp.net class and thats
my problem


thanks
 
K

Kevin Spencer

I *did* read carefully, Xavier. However, without good information from you,
I can't be of much help.

Here's what you say the line of code that throws the error says:
Dim oExternalLib As New MyCompany.FBLib1

Here's the error message:
C:\Inetpub\10.118.164.237_81\WebApp1\WebForm1.aspx.vb(33): Type
'MyCompany.FBLib1' is not defined.

Here's your class definition:

I don't see *any* class named "FBLib1." Therefore, what you're telling me
you're doing, and what you're doing are 2 entirely different things. I can
only guess. The error message indicates that "MyCompany.FBLib1" is not
defined. I have yet to see any definition of it myself. What I *have* seen a
definition of is two classes:
"MyCompany.InternalTest.MyCompany_InternalClass" and
"MyCompany1.InternalTest.MyCompany_InternalClass".

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
G

Guest

sorry - here are all details to reproduce the errorr in VS2003 (.NET 1.1)

create a solution with 2 projects
a -> a classlibrary with the Name FBlib
b ->a asp.net application with the name Webapp1


1*- create a new class library (FBlib) with only a class ( root namespace
in property of VS i deleted)
Content of the classfile FBLib1.vb

Namespace MyCompany
Public Class FBLib1
Function FBEcho(ByVal vIn As String) As String
Return vIn
End Function
End Class
End Namespace

2*add a asp.net project (Webapp1) with
a) a ClassFile - FileName MyCompany.InternalClass.vb content:

Namespace MyCompany1.InternalTest
Public Class MyCompany_InternalClass
Public Function Test() As String
Return "InternalTest"
End Function
End Class
End Namespace

b) create a standard aspx page WebForm1.aspx with code behind
c) add a project reference to the ClassLibrary (FBLib) - created in step 1
d)add to the aspx page a 2 labels (Label1 and Label2) and a button
e)in the button event add please

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim oExternalLib As New MyCompany.FBLib1
Label1.Text = oExternalLib.FBEcho("Hello-from externalLib")

Dim oInternalClass As New
MyCompany1.InternalTest.MyCompany_InternalClass
Label2.Text = oInternalClass.Test
End Sub

3*STRG + F5 - click on the button and the aspx page will display

Hello-from externalLib
InternalTest

still here all works OK

4*error reproducion

a)change in the file from step 2a the namespace
Namespace MyCompany1.InternalTest TO -> Namespace MyCompany.InternalTest

b)in WebForm1.aspx.vb correct the line

from Dim oInternalClass As New MyCompany1.InternalTest.MyCompany_InternalClass
to Dim oInternalClass As New MyCompany.InternalTest.MyCompany_InternalClass


and no compilation is possible - error in line
Dim oExternalLib As New MyCompany.FBLib1 - is displayed !!!!!!!!!!!!
C:\Inetpub\10.118.164.237_81\WebApp1\WebForm1.aspx.vb(31): Type
'MyCompany.FBLib1' is not defined.


i hope now you can reproduce the error
thanks
 
K

Kevin Spencer

It looks to me like you didn't update your reference. See Step 2c:
c) add a project reference to the ClassLibrary (FBLib) - created in step 1

In your explanation, you did not mention anything about updating the
reference.

It might help if you just post the code verbatim. No need to post the code
that worked, just the code that didn't.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
G

Guest

you see that in step 3 all works - i can call the function from the FBib....

The problem apears only when i change in the asp.net project the value of
the namespace how discribed in 4 a and b.

Can you please try to create this short solution how described in the steps
1 -3,4 then you could very simple reproduce the error and we could see if
this is a bug in VS2003

thanks
 
K

Kevin Spencer

Can you please try to create this short solution how described in the
steps
1 -3,4 then you could very simple reproduce the error and we could see if
this is a bug in VS2003

No, I don't have time for that. I told you what it looked like the problem
was. It is not a bug in VS.Net.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
G

Guest

i fully understand that you have no time, but i think it is a bug in VSNet
because all works ok still i did not use the same Namespace as the Namespace
of the external lib.

thanks for your help.
 

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