Link to home
Start Free TrialLog in
Avatar of -Dman100-
-Dman100-Flag for United States of America

asked on

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.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

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
Avatar of -Dman100-

ASKER

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.
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
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.
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
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.
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
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?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial