Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

adding generated code from a dataset to a class library

I'm new to working with class libraries.  I know that a class library compiles into an assembly that you can use in your applications.

Here is my question.  I am managing an application that has a class library.   I need to add some new code to the class library and generated an updated assembly.

Outside of the class library project, I have another web application project and I added a new dataset that has two datas tables and two table adapters.  I have a page that uses these table adapters to bind to a couple of repeaters that dispaly the information from the data tables.  All that works fine.

Now, what I want to do, is move the code into the class library and re-compile, so the code from the dataset can be rolled up into the assembly.

I have no idea how to do this?

Can anyone help?  I would greatly appreciate any guidance on how to accomplish this.

Thank you.
0
-Dman100-
Asked:
-Dman100-
  • 5
  • 4
1 Solution
 
Bob LearnedCommented:
If you are looking to generate dynamic code, then look into CodeDom.  I don't think that you will not be able to modify an existing class library.  You can, however, compile the code in to a separate AppDomain, so that you can load/unload the DLL.

CodeDom Example:

How Do I...Use the CodeDOM to emit source code?
http://quickstart.developerfusion.co.uk/QuickStart/howto/doc/listbuilder.aspx

Bob
0
 
-Dman100-Author Commented:
Hi Bob,

Thanks for replying to my post.  So, I cannot add the classes created by the Dataset into the existing class library.  Since I have the class library, I can add new classes and re-compile, which is why I thought I could add the classes generated by the dataset into this class library, but there is no way to accomplish that?

Is you suggested, how can I compile the code created by the Dataset as another class library?  Sorry, for the novice questions, I've just never done this before,.

Thanks for your help.
0
 
Bob LearnedCommented:
I think that I misunderstood your question.  I doesn't sound like you aren't talking about generating dynamic code, but more about moving a typed DataSet into a class library.  Is this right?

Bob
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
-Dman100-Author Commented:
Hi Bob,

Yes, that is correct.  I just want to move the typed Dataset code into the class library and re-compile the assembly so the typed dataset will be included in the assembly.  Am I articulating what I want to accomplish correctly?

Thanks for your help.
0
 
Bob LearnedCommented:
It sounds like you want to put all of your data access stuff into a single DLL.  You should be able to move all the related files for the DataSet into another assembly (if I understand what you're asking), and then add a data access layer class that will be able to work with the DataSet.

Bob
0
 
-Dman100-Author Commented:
Bob,

Yes, I want to use a single DLL.

How do I move the related files for the Dataset into the class library.  There is already a data access layer in the class library.  I guess I need ot create the new class to work with the DataSet.

Is there an article that describes how to do this?

I'm still relatively new to .NET and know how to create the dataset and bind controls using the TableAdapters created in the dataset, but just not how to move those into a class library.
0
 
Bob LearnedCommented:
1) There are 4 files associated with a typed DataSet:

DataSet1.xsd
DataSet1.Designer.cs
DataSet1.xsc
DataSet1.xss

2) Open Windows Explorer, and move the files from the current folder to the class library folder.  

3) Modify the .csproj to remove the files from the main project, and include them in the class library project.

4) In the data access layer class, create an instance of a typed DataSet, and provide methods to get access to the dataset.

Bob
0
 
-Dman100-Author Commented:
Sorry to be such a pain, but I had a few questions to the steps you listed.

1)  I see the CustomerService.xsd and CustomerService.xss files, but I don't see the CustomerService.Designer.cs file or the CustomerService.xsc files?  Not sure why?  I don't see them in the AppCode folder?

2) Okay, no problem with this one

3)  Not sure how to modify the .csproj file to accomplish this?

4) I might be asking a completely stupid question here, but when the typed dataset was created, didn't it create the methods that access the data that is populated from the database?

I hope my questions make sense and I'm not completely lost?
0
 
Bob LearnedCommented:
That description for the files was based on a WinForms application.  For an ASP.NET web site, there would only be the .xsd and the .xss file.

You should be able to use the typed DataSet directly, without any other class required.

Bob
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now