irfantak
asked on
ASP .NET a 'namespace' but is used like a 'type' error
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
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
that is, instead of Using, try Imports
ASKER
Okay...
ASKER
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.
'A namespace does not directly contain members such as fields or methods'
pointing to: 'Imports RichChart;' part of the code.
Thanks.
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()
ASKER
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.
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.
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();
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();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
ASKER
Yes,
System.Text.StringBuilder totalOwner = new System.Text.StringBuilder( );
got rid of the last error.
Thank you for your help!
System.Text.StringBuilder totalOwner = new System.Text.StringBuilder(
got rid of the last error.
Thank you for your help!
instead of using RichChart;
try
Imports RichChart;