?
Solved

ASP .NET a 'namespace' but is used like a 'type' error

Posted on 2007-04-04
10
Medium Priority
?
2,417 Views
Last Modified: 2008-01-09
Asp .Net C#. Getting Error 'RichChart' is a 'namespace' but is used like a 'type'. The RichChart.RichChart.dll is located in the application's BIN folder.

Here is what I am trying to do: Convert all code which is in an ASPX file to a Codefile.
---------Code in the ASPX file---
.... (Not Code Behind file)
<%@ Import Namespace="RichChart" %>
.....
// create the RichChart object:
 RichChart rc = new RichChart();

------------Problematic Code in the new setup with the Codefile (.cs)----------
using RichChart;
...
 // create the RichChart object:
 RichChart rc = new RichChart();//Generates above error



0
Comment
Question by:irfantak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 12

Expert Comment

by:craskin
ID: 18852840
it works on the aspx but not if you use it on the codebehind?

instead of using RichChart;

try

Imports RichChart;
0
 
LVL 12

Expert Comment

by:craskin
ID: 18852847
that is, instead of Using, try Imports
0
 

Author Comment

by:irfantak
ID: 18852853
Okay...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:irfantak
ID: 18852874
See a new error now

'A namespace does not directly contain members such as fields or methods'
 pointing to: 'Imports RichChart;' part of the code.

Thanks.
0
 
LVL 12

Expert Comment

by:craskin
ID: 18852973
that makes some sense. it sound like the RichChart namespace does not have constructors of its own. so it should be something like RichChart.SomethingElse()
0
 

Author Comment

by:irfantak
ID: 18853008
Well, the DLL is named as RichChart.RichChart.dll and I have already tried using Imports RichChart.RichChart but same error.

I don't know why a relatively simple stuff like migrating fhe code from the main .aspx to the codefile of .cs is becoming such an issue.

Any ideas?
Thanks.
0
 
LVL 12

Expert Comment

by:craskin
ID: 18853079
Imports RichChart should stay the same and that's equivalent to <% Import Namespace... on the aspx page.

but without knowing anything about the source in the dll, it's hard to say what your syntax on the codebehind should be. it's probably

RichChart rc = new RichChart.RichChart();
0
 
LVL 12

Accepted Solution

by:
craskin earned 1000 total points
ID: 18853098
what the developer has probably done is to create a RichChart object within the RichChart namespace. the object has all the methods and properties and the namespace has only the object, which is why you can't create a new RichChart without creating a RichChart.RichChart.
0
 

Author Comment

by:irfantak
ID: 18853144
Kind of progress. I am still using 'using RichChart;' in top of the .CS file but the following changed

 RichChart.RichChart rc =  new RichChart.RichChart();

Now there is another error, serveral lines down:
The type or namespace name 'StringBuilder' could not be found (are you missing a using directive or an assembly reference?)
'StringBuilder totalOwner = new System.Text.StringBuilder();'

Is the error happening because I have to fully qualify the Assemblies/Namespaces (because now the code is in the .CS file)?

Anyway, thanks.
0
 

Author Comment

by:irfantak
ID: 18853161
Yes,

 System.Text.StringBuilder totalOwner = new System.Text.StringBuilder();

got rid of the last error.

Thank you for your help!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question