Tutorial: Compiling the generated code and setting up the solution.
Preface
In the
previous tutorial, we generated sourcecode from an LLBLGen Pro project in the designer after having mapped some entities, a typed view and a retrieval stored procedure call. In this tutorial, we'll open the generated Visual Studio.NET 2005 (VS.NET 2005) projects in VS.NET 2005 and compile the generated code and as well add a console project, setup the correct references so we can add our own code using the generated code to use the data in the Northwind database. This tutorial is divided into two sub tutorials: one for Adapter and one for SelfServicing.
A similar (more limited) tutorial is also available in a Flash movie format on our website:
Tutorial - VS.NET: compiling a generated project (opens in new window)
Adapter: Setting up the Solution
Please follow the following steps to load the generated VS.NET 2005 projects into VS.NET, setting up the correct references, adding a console project and compile the whole solution. This part is for Adapter. If you're more interested in SelfServicing, see the
SelfServicing section below.
- Start VS.NET 2005.
- Select File -> Open -> Project / Solution or press Cntrl-shift-O. The file browse dialog of VS.NET 2005 opens. Browse to the folder into which you've generated the code, namely the folder you've specified for Destination root folder on the first tab of the code generation configuration dialog. The folder will contain two projects, Northwind.Tutorial.csproj (or vbproj if you've selected VB.NET instead) and Northwind.TutorialDBSpecific.csproj (or .vbproj). Select Northwind.Tutorial.cs/vbproj and click Open.
- VS.NET has now created a solution for you and has loaded the database generic part of the Adapter sourcecode. We'll now load the database specific part as well. In VS.NET's Solution Explorer, Right-click the Solution node -> Add -> Existing project. Browse again to the Destination root folder and select Northwind.TutorialDBSpecific.cs/vbproj and click Open.
- VS.NET now has both the LLBLGen Pro generated vs.net projects loaded. By default, the generated projects should have the correct references setup. If you have LLBLGen Pro v2.0 or v1.0.2005.1 installed as well, it could be VS.NET 2005 made a mistake and referenced the old .NET 2.0 LLBLGen Pro runtime libraries. If you're using C#, in Solution Explorer, click open the References node in both VS.NET projects, select the SD.LLBLGen.Pro.ORMSupportClasses.NET20 assembly and in the Properties window (Press F4 if it's not visible) it should say Version 2.5.0.0. If it doesn't, you should remove the reference and instead add a reference to the v2.5 version of the SD.LLBLGen.Pro.ORMSupportClasses.NET20 dll. In the DBSpecific project, you will also find a reference to the SqlServer DQE engine assembly. This too has to be v2.5. If it's not, remove the reference and instead add a reference to the v2.5 version of SD.LLBLGen.Pro.DQE.SqlServer.NET20 dll.
If you're using VB.NET, you can check the references by checking the project properties of each project loaded into VS.NET.
- The references are now OK, so we could go on and compile the sourcecode by pressing cntrl-shift-B. This should lead to a successful compilation.
- For our next tutorial, we'll use a console application which will use the generated code. In the Solution Explorer, Right-click the solution node -> Add -> New project. The new project dialog opens. For your language of choice, e.g. C# or VB.NET, select Console Application and specify for Name: NorthwindConsole and for Location the folder into which the generated code was generated, the folder you've specified for Destination root folder or a parent folder of that, e.g. C:\temp\NorthwindTutorial\ and click OK
- VS.Net will now create a console application in our solution. As VS.NET isn't that bright to automatically make our console application the startup project, in Solution Explorer Right-click the NorthwindConsole project -> Set as startup project.
- If you're using C#, you've to setup the references in the Solution Explorer, if you're using VB.NET, you should open the Properties of the NorthwindConsole project and add the references there. For the NorthwindConsole project, add a reference to the SD.LLBLGen.Pro.ORMSupportClasses.NET20 assembly. Also add references to both the Northwind.Tutorial and Northwind.TutorialDBSpecific projects.
- LLBLGen Pro automatically generates an app.config file in the DBSpecific project. We will use that one in our NorthwindConsole project. In Solution Explorer click open the Northwind.TutorialDBSpecific project's DatabaseSpecific folder and select and drag the App.config file to the NorthwindConsole project. VS.NET will copy the file for us.
You're now ready for the next tutorial where we will add code to our console application. Check the setup of the solution by compiling it with cntrl-shift-B and also save the solution to a folder, for example the parent of the folder you've specified with Destination root folder.
SelfServicing: Setting up the Solution
Please follow the following steps to load the generated VS.NET 2005 projects into VS.NET, setting up the correct references, adding a console project and compile the whole solution. This part is for SelfServicing.
- Start VS.NET 2005.
- Select File -> Open -> Project / Solution or press Cntrl-shift-O. The file browse dialog of VS.NET 2005 opens. Browse to the folder into which you've generated the code, namely the folder you've specified for Destination root folder on the first tab of the code generation configuration dialog. The folder will contain one projects, Northwind.Tutorial.csproj (or vbproj if you've selected VB.NET instead). Select Northwind.Tutorial.cs/vbproj and click Open.
- VS.NET has now created a solution for you and has loaded the database generic part of the Adapter sourcecode. By default, the generated project should have the correct references setup. If you have LLBLGen Pro v2.0 or v1.0.2005.1 installed as well, it could be VS.NET 2005 made a mistake and referenced the old .NET 2.0 LLBLGen Pro runtime libraries. If you're using C#, in Solution Explorer click open the References node in the VS.NET project, select the SD.LLBLGen.Pro.ORMSupportClasses.NET20 assembly and in the Properties window (Press F4 if it's not visible) it should say Version 2.5.0.0. If it doesn't, you should remove the reference and instead add a reference to the v2.5 version of the SD.LLBLGen.Pro.ORMSupportClasses.NET20 dll. You will also find a reference to the SqlServer DQE engine assembly. This too has to be v2.5. If it's not, remove the reference and instead add a reference to the v2.5 version of SD.LLBLGen.Pro.DQE.SqlServer.NET20 dll.
If you're using VB.NET, you can check the references by checking the project properties of the project loaded into VS.NET.
- The references are now OK, so we could go on and compile the sourcecode by pressing cntrl-shift-B. This should lead to a successful compilation.
- For our next tutorial, we'll use a console application which will use the generated code. In the Solution Explorer, Right-click the solution node -> Add -> New project. The new project dialog opens. For your language of choice, e.g. C# or VB.NET, select Console Application and specify for Name: NorthwindConsole and for Location the folder into which the generated code was generated, the folder you've specified for Destination root folder or a parent folder of that, e.g. C:\temp\NorthwindTutorial\ and click OK
- VS.Net will now create a console application in our solution. As VS.NET isn't that bright to automatically make our console application the startup project, in Solution Explorer Right-click the NorthwindConsole project -> Set as startup project.
- If you're using C#, you've to setup the references in the Solution Explorer, if you're using VB.NET, you should open the Properties of the NorthwindConsole project and add the references there. For the NorthwindConsole project, add a reference to the SD.LLBLGen.Pro.ORMSupportClasses.NET20 assembly. Also add a reference to the Northwind.Tutorial project.
- LLBLGen Pro automatically generates an app.config file in the SelfServicing project. We will use that one in our NorthwindConsole project. In Solution Explorer click open the Northwind.Tutorial project folder and select and drag the App.config file to the NorthwindConsole project. VS.NET will copy the file for us.
You're now ready for the next tutorial where we will add code to our console application. Check the setup of the solution by compiling it with cntrl-shift-B and also save the solution to a folder, for example the parent of the folder you've specified with Destination root folder.