Typed dataset not recognized when moved to another project
Asked Answered
E

5

2

I moved a typed dataset from one project to an ASP Web Application project. I put the typed dataset into one of the existing directories as it was in the App_Code directory of the previous site but don't see the option to create that asp.net folder in this project.

Now, when I try to instantiate the typed dataset, the compiler says 'The type or namespace name '' could not be found (are you missing a using directive or an assembly reference?)'.

Thoughts?

Electromagnetism answered 31/12, 2008 at 14:49 Comment(0)
S
7

You may need to re-gen the DataSet. When you move the .xsd, you've only moved the xml layout of the DataSet.

Delete any generated code file, open the xsd, move something, and then save it. The save operation calls the generator. Or you can right-click on the .xsd file and call the generator directly.

Semitrailer answered 31/12, 2008 at 15:6 Comment(1)
Just to clarify - this does work. You can expand the XSD in the Solution Explorer, and simply delete the Designer.vb file. Then open your dataset (XSD file) and drag the dataset a little bit. Then Save. I couldn't see what it actually changes in the Designer file.Hudnut
V
4

I moved my web site to a Web Application Project and experienced the same issues. I took the approach mentioned in the first answer and was able to get the project to compile eventually. I would like to add a little more detail to the first answer.

To be explicit: I first deleted all of the files associated with the xsd file except for the xsd file itself (the xss, xsc, cs, ...). I then right-clicked on the xsd file, selecting "View Designer" and then "View Code", and then "Run Custom Tool". All of the files were re-gened and the references compiled.

Vampirism answered 27/4, 2009 at 21:11 Comment(0)
C
3

Make sure the compiler knows it's a dataset and not just an Xml file. Select the DataSet.xsd in Solution Explorer, then in the Project window ensure that "Custom Tool" is set to MSDataSetGenerator.

After that, instead of guessing, open up the dll file in Reflector and look for your DataSet class. Make sure it's in the namespace you think it is.

Chervil answered 24/4, 2009 at 19:21 Comment(1)
I had a blank CustomTool setting, so no code was getting generated. This fixed it, cheersWenonawenonah
S
1

In Visual Studio 2015, what I did was

  1. Before I right-click the added dataset to Include in project, I deleted the .xss and .xsc files and left the rest.

  2. I then right-click the .xsd file and included in the project and problem solved.

Hope I solved someone's problem.

Sackey answered 10/8, 2016 at 22:35 Comment(0)
A
0

You have included the "using namespace" statement in the new code?

Aliped answered 31/12, 2008 at 14:56 Comment(2)
Yes. When I did that and the compiler says 'Type or namespace name not be found <namespace>'. I referenced newly imported classfiles from another namespace just fine. The typed dataset is the only file so far it it's namespace.Electromagnetism
Confirm if there is namespace in a .cs file generated from .xsd (right-click on .xsd > "View Code"). There is a "Custom Tool Namespace" you can specify in XSD file properties - check out if assigning it helps.Unasked

© 2022 - 2024 — McMap. All rights reserved.