This is a migrated thread and some comments may be shown as answers.

VS 2010, TFS, MSBuild, UnitTest, OpenAccess

12 Answers 365 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Per
Top achievements
Rank 1
Per asked on 10 Jun 2010, 01:45 PM
Hi

I have a solution containing 5 projects.
Project 1: Data Access Layer, A layer using OpenAccess to query a MS SQL 2008 Db
Project 2: Model Layer, Contains persisted classes used as transfer objects between the layers. OA have created these.
Project 3: Business Logic Layer
Project 4: ASP.Net 4.0 Web Site using Business Logic Layer to get information form the database
Project 5: UnitTests

We are using TFS 2010 and have a sperate Build Server.
This server has also a Test Agent installed and Open Access is locally deployed.
We have 2 build definitions:
"Continuous Build", this is run when a user checks in code.
"Daily Build", this is run every night and are using MSBuild to deploy the web to QA.

We are using Telerik Project Dashboard to follow the teams work.
We are running all unittests when the "Continuous Build" us run.
We are using the latest versions of all Telerik products.
I have read all your blogs&posts on the MSBuild/Enhancer topic but I still can't figure this out :(

Now to my questions :)
1) What classes need to be enhanced in this setup?
2) What the best abroach to enhance these classes (MSBuild or VS extension, Command Line or change process template)?
2) Is its possible to get Code Coverage values from the Test Agents when Open Access is used?
3) How should we setup the ObjectScope in our web project? (The MS Unit Test setup described in the help section of OA contradicts the best setup for OA scope for web sites)

At the moment we receive the "Telerik.OpenAccess.Exceptions.MetadataException: HighLow Key Generator failure for class" when the unit tests are run (on the build server).
When we changed to use msbuild we received the "cannnot find section OpenAccess in the app.config".

I'm confused :(

Regards
Per


12 Answers, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 10 Jun 2010, 03:37 PM
Hi Per,

1. all OpenAccess persistent classes will have to be enhanced
2. in order to enhance assemblies as part of the build process on a build machine you will have to  use the msbuild approach for enhancing (but then you will need to have the enhancer and all OpenAccess assemblies that your projects need checked-in in source control).
3. the code coverage instrumentation should work fine with the new enhancer (release 2010 Q1 SP1 and above)
4. the topic in our current documentation regarding MS Test is reflecting a simple desktop scenario. If you are testing you web site code, you should use the same method that you use for obtaining the scope in your web site e.g. using the best practices approach that is described in other articles.

About the exception that you are getting: this is probably because in the app.config file for the executing assembly (the test assembly) the open access configuration is missing or incomplete.
You have two options here:
1. call the static AdjustForDynamicLoad method of your object scope provider class (I would try with this first)
2. add a reference to your model assembly in the OpenAccess configuration like bellow:
    <references>
      <reference assemblyname="Telerik.OpenAccess.Tests.CSModel" configrequired="true" />
    </references>
    <backendconfigurations>

I hope this helps. Do not hesitate to write again if you have more questions.

Sincerely yours,
Zoran
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Per
Top achievements
Rank 1
answered on 10 Jun 2010, 09:36 PM
Hi and thanks for your quick response :)

I did as you suggested and are now using the MSBuild task aproche to enhance my model assembly.

Unfortently, all my tests fails with this error message:
Unable to create instance of class Links.Rubix.UnitTest.AdministrationServiceTest. Error: Telerik.OpenAccess.OpenAccessException: No metadata has been registered for class Links.Rubix.Model.ActivityType. (This usually indicates, that either this class is not declared persistent or it is declared persistent but not enhanced. The class was loaded from file:///C:/Builds/Agent_3/Rubix/Continuous build/TestResults/Administrator_BLDSRV 2010-06-10 22_18_08_Any CPU_Debug/Out/Links.Rubix.Model.DLL.)

If I look at the build log, I can see that the Model assembly is enhanced (at least what I can see)

I'm lost, any other suggestions ?

Regards
Per

BTW, There is a code typo in the page http://www.telerik.com/help/openaccess-orm/openaccess-msbuild-integration.html
The code examples that shows the OpenAccessEnhancer task, is missing a ">" (closing tag) on a few places.

My Build log:

OpenAccessEnhancer:
  "C:\Program Files (x86)\Telerik\OpenAccess ORM\sdk\enhancer.exe" -verboseMode:3 -assembly:"C:\Builds\Agent_3\Rubix\Continuous build\Sources\Model\obj\Debug\Links.Rubix.Model.dll" -keyFile:"" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.CSharp.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.DataSetExtensions.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Runtime.Serialization.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.Linq.dll" -reference:"C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.35.Extensions.dll" -reference:"C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.dll" -reference:"C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.Web.dll" -reference:"C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.Windows.dll" -attributeMapping -xmlMapping:"App.Config"
  Telerik OpenAccess Enhancer, Version 2010.1.531.1, Copyright (C) 1996-2010 Telerik
  Creating "obj\Debug\Links.Rubix.Model.oa" because "AlwaysCreate" was specified.
  2010.1.531.1
_CopyFilesMarkedCopyLocal:
  Copying file from "C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.35.Extensions.dll" to "C:\Builds\Agent_3\Rubix\Continuous build\Binaries\Telerik.OpenAccess.35.Extensions.dll".
  Copying file from "C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.Web.dll" to "C:\Builds\Agent_3\Rubix\Continuous build\Binaries\Telerik.OpenAccess.Web.dll".
  Copying file from "C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.Windows.dll" to "C:\Builds\Agent_3\Rubix\Continuous build\Binaries\Telerik.OpenAccess.Windows.dll".
  Copying file from "C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.35.Extensions.xml" to "C:\Builds\Agent_3\Rubix\Continuous build\Binaries\Telerik.OpenAccess.35.Extensions.xml".
  Copying file from "C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.Web.xml" to "C:\Builds\Agent_3\Rubix\Continuous build\Binaries\Telerik.OpenAccess.Web.xml".
  Copying file from "C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.Windows.xml" to "C:\Builds\Agent_3\Rubix\Continuous build\Binaries\Telerik.OpenAccess.Windows.xml".
CopyFilesToOutputDirectory:
  Copying file from "obj\Debug\Links.Rubix.Model.dll" to "C:\Builds\Agent_3\Rubix\Continuous build\Binaries\Links.Rubix.Model.dll".
  Model -> C:\Builds\Agent_3\Rubix\Continuous build\Binaries\Links.Rubix.Model.dll
  Copying file from "obj\Debug\Links.Rubix.Model.pdb" to "C:\Builds\Agent_3\Rubix\Continuous build\Binaries\Links.Rubix.Model.pdb".
AfterBuild:
  "C:\Program Files (x86)\Telerik\OpenAccess ORM\sdk\enhancer.exe" -verboseMode:0 -assembly:"C:\Builds\Agent_3\Rubix\Continuous build\Sources\Model\obj\Debug\Links.Rubix.Model.dll" -keyFile:"" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.CSharp.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.DataSetExtensions.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Runtime.Serialization.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll" -reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.Linq.dll" -reference:"C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.35.Extensions.dll" -reference:"C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.dll" -reference:"C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.Web.dll" -reference:"C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.Windows.dll" -attributeMapping
  Telerik OpenAccess Enhancer, Version 2010.1.531.1, Copyright (C) 1996-2010 Telerik
Done Building Project "C:\Builds\Agent_3\Rubix\Continuous build\Sources\Model\Model.csproj" (default targets).
0
Per
Top achievements
Rank 1
answered on 11 Jun 2010, 12:43 PM
I noticed something else that is kinda strange.

I changing the .csproj file (for my model project) to include the OpenAccess.targets import and a AfterBuild taks :
  <Target Name="AfterBuild">  
    <OpenAccessEnhancer VerboseMode="2" Assembly="$(TargetPath)">  
      <Output TaskParameter="Version" PropertyName="OpenAccessEnhancerVersion" /> 
    </OpenAccessEnhancer> 
  </Target> 
I also set the "UseMSBuild" property to True and Enhancing to "True".

Now when I try and run my project in VS I receive this error:
No metadata has been registered for class Links.Rubix.Model.Report. (This usually indicates, that either this class is not declared persistent or it is declared persistent but not enhanced. The class was loaded from file:///C:/Users/pebo/Documents/Visual Studio 2010/Projects/Rubix/Source/Web/bin/Links.Rubix.Model.DLL.)

I can no longer see that the enhancer is run in my output window.

Is its possible to get both MSBuild and VS working at the same time?

Regards
Per
0
Zoran
Telerik team
answered on 17 Jun 2010, 05:51 PM
Hi Per,

You should not import the OpenAccess.targets file when you are working using the standard OpenAccess approach e.g. having persistent classes generated with the Reverse or Forward Mapping Wizards. The OpenAccess.targets needs to be imported when you use the new Visual Designer mapping  approach. So I suggest you to remove that part of the project file. Which approach did you try for linking with the model assembly? Did you write the references section in the app.config file of the test project or did you call the AdjustForDynamicLoad(). I would suggest you also to combine these methods and add the references section in your Test project's App.config and also call AdjustForDynamicLoad on your test class initialize.

Best wishes,
Zoran
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Per
Top achievements
Rank 1
answered on 18 Jun 2010, 10:28 PM
Hi and thanks for your reply :)

The current status is this:
1) I have removed includes as you suggested.
2) In my test project, I have a App.Config file that looks like this:
<?xml version="1.0"?>  
<configuration> 
  <configSections> 
    <section name="openaccess" type="Telerik.OpenAccess.Config.ConfigSectionHandler, Telerik.OpenAccess.Config, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342" requirePermission="false" /> 
  </configSections> 
  <openaccess xmlns="http://www.telerik.com/OpenAccess">  
    <references> 
      <reference assemblyname="Links.Rubix.Model" configrequired="True" /> 
      <reference assemblyname="Links.Rubix.DataAccess.Relational" configrequired="True" /> 
    </references> 
  </openaccess> 
</configuration> 
3) In my Relational project, I have a App.Config file that looks like this:
<?xml version="1.0"?>  
<configuration> 
  <configSections> 
    <section name="openaccess" type="Telerik.OpenAccess.Config.ConfigSectionHandler, Telerik.OpenAccess.Config, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342" requirePermission="false" /> 
  </configSections> 
  <openaccess xmlns="http://www.telerik.com/OpenAccess">  
    <references> 
      <reference assemblyname="Links.Rubix.Model" configrequired="True" /> 
    </references> 
  </openaccess> 
</configuration> 

Both my projects (Relation and Model) have Enhancing set to true and MSBuild set to false.

After the build server has build the projects, I receive the following error when the tests are run:

Unable to create instance of class Links.Rubix.UnitTest.AdministrationServiceTest. Error: System.Configuration.ConfigurationErrorsException: Telerik.OpenAccess: No enhanced assembly has been found for meta-data construction. This may be caused by a missing app.config file (use app.config as embedded resource then) or by an insufficient references section in the configuration file (add the referenced enhanced assemblies there too) or by a wrong enhancement setting; please check your configuration..

Any idea where I should start looking?
(Build action is set to Embedded resource on all App.Config files)

Regards
Per
0
Zoran
Telerik team
answered on 24 Jun 2010, 06:50 PM
Hello Per,

 In this configuration, are the classes enhanced at the end? You could check this out with the .NET Reflector. This is important so that we know if the setup on your build server is the cause for the problems e.g. the classes are not enhanced or if the testing project does not see the required classes even though they are enhanced? Maybe the enhancer is not called at all on your build server, which is the most probable case, otherwise we should look into the implementation of your test project and see what could be improved there.

Kind regards,
Zoran
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Per
Top achievements
Rank 1
answered on 29 Jun 2010, 07:07 PM
Hi

I can now confirm that the VEnhancer.exe is not executed during the msbuild processon on my TFS 2010 build server.
After I manually run the venhancer.exe on the required assemblies, my tests works fine.

What do I have to do to get the VEnhancer.exe to execute after msbuild have compiled my projects?

Regards
Per
0
Jordan
Telerik team
answered on 06 Jul 2010, 03:21 PM
Hello Per,

It turns out that if you want to use the old enhancer from a recent version of OpenAccess with msbuild you cannot use the OpenAccess.targets file out of the box. This is because in recent versions the targets in this file are written to work with the new enhancer. And if you want to use the old enhancer you will have to use the commented targets at the end of the file.

I have attached the old version of the targets file together with a project file that uses it so that you do not have to deal with the new targets file.

Also there is a solution that uses OpenAccess and is setup in such a way that you can build it (enhancing included) without having OpenAccess installed. And this solution even is setup to use the old enhancer. So you can use it as a sample to setup your solution.
You can download the whole project from here:
http://www.telerik.com/community/labs/sales-dashboard-for-winforms.aspx

It is very important that you specify the path to the OpenAccess files at the beginning of the targets file so that it correctly reflects your setup.

I hope this helps.

All the best,
Jordan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Per
Top achievements
Rank 1
answered on 08 Jul 2010, 10:39 AM
Hi

Tanks for the file.
After installing the file, and changing the settings according to the solution you refereed to, it compiles fine and the unit tests are run when I run it on the build server.

However, the test can now not be run on the local computer.
When I build the solution, I can no longer see that the Enhancer is run (judging from the information in the Output window) but the web is working. How is this possible?
(If I change the msbuild variable on a project to false, I can once again see the enhancer running in the output window.)

When I try and execute a unit test on the local computer, the tests failes with one of theese errors:
Initialization method Links.Rubix.UnitTest.AuthorizationServiceTest.TestBaseInitialize threw exception. Telerik.OpenAccess.OpenAccessException: Telerik.OpenAccess.OpenAccessException: No metadata has been registered for class Links.Rubix.Model.PostCategory. (This usually indicates, that either this class is not declared persistent or it is declared persistent but not enhanced. The class was loaded from file:///C:/Users/pebo/Documents/Visual Studio 2010/Projects/Rubix/Dev/Source/TestResults/pebo_PER-PC 2010-07-08 11_36_43/Out/Links.Rubix.Model.DLL.).

or

Class Initialization method Links.Rubix.UnitTest.AdministrationServiceTest.MyClassInitialize threw exception. Telerik.OpenAccess.Exceptions.ConfigurationException: Telerik.OpenAccess.Exceptions.ConfigurationException: The 'openaccess' section cannot be found in the application's configuration file..

This is the output window from unit test run build:

------ Build started: Project: Model, Configuration: Debug Any CPU ------

Model -> C:\Users\pebo\Documents\Visual Studio 2010\Projects\Rubix\Dev\Source\Model\bin\Debug\Links.Rubix.Model.dll

------ Build started: Project: Shared, Configuration: Debug Any CPU ------

Shared -> C:\Users\pebo\Documents\Visual Studio 2010\Projects\Rubix\Dev\Source\Shared\bin\Debug\Links.Rubix.Shared.dll

------ Build started: Project: DataAccess.Relational, Configuration: Debug Any CPU ------

Model -> C:\Users\pebo\Documents\Visual Studio 2010\Projects\Rubix\Dev\Source\Model\bin\Debug\Links.Rubix.Model.dll

DataAccess.Relational -> C:\Users\pebo\Documents\Visual Studio 2010\Projects\Rubix\Dev\Source\DataAccess.Relational\bin\Debug\Links.Rubix.DataAccess.Relational.dll

------ Build started: Project: DataAccess.OLAP, Configuration: Debug Any CPU ------

DataAccess.OLAP -> C:\Users\pebo\Documents\Visual Studio 2010\Projects\Rubix\Dev\Source\DataAccess.OLAP\bin\Debug\Links.Rubix.DataAccess.OLAP.dll

------ Build started: Project: Services, Configuration: Debug Any CPU ------

Services -> C:\Users\pebo\Documents\Visual Studio 2010\Projects\Rubix\Dev\Source\Services\bin\Debug\Links.Rubix.Services.dll

------ Skipped Build: Project: Test, Configuration: Debug Any CPU ------

Project not selected to build for this solution configuration

========== Build: 5 succeeded or up-to-date, 0 failed, 1 skipped ==========

========== OpenAccess All: 0 succeeded, 0 failed, 3 skipped ==========

Regards
Per

0
Jordan
Telerik team
answered on 09 Jul 2010, 02:15 PM
Hello Per,

It seems to me that you are judging that the enhancer has not ran based on the build output that says:
========== OpenAccess All: 0 succeeded, 0 failed, 3 skipped ==========

But you must have in mind that this output comes from the OpenAccess addin and actually this is what you want to see, because you have specified that you are using msbuild to do the enhancing and the addin should not do it.

Looking at the exceptions that you get, it seems to me that OpenAccess cannot find its configuration.
Did you try to call the AdjustForDynamicLoad() method before using the persistent classes?
Try using the AdjustForDynamicLoad() method and if you still face issues I could prepare a sample solution that has a model, enhanced using msbuild and is used in a unit test project.

Sincerely yours,
Jordan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Per
Top achievements
Rank 1
answered on 09 Jul 2010, 02:54 PM
Hi

I can confirm that the classes are enhanced, but how can I check if its enhanced using the enhancer.exe or the venhancer.exe ?

I am using AdjustForDynamicLoad so I think that is right.
The web site is working fine localy when I do a Clean and then a Full Compile, so the enhancer must we working when I do a Debug (F5) or a Run.
The problem occures if I inside VS 2010 clicka on the "Test" menu, then "Windows" and "Test List Editor".
From there I selected to "Run Test in Current Context" (Ctrl + R, T).

It now recompiles the all the projects but all tests failes with:
Initialization method Links.Rubix.UnitTest.AuthorizationServiceTest.TestBaseInitialize threw exception. Telerik.OpenAccess.OpenAccessException: Telerik.OpenAccess.OpenAccessException: No metadata has been registered for class Links.Rubix.Model.PostCategory. (This usually indicates, that either this class is not declared persistent or it is declared persistent but not enhance)

When the tests are run on the build server, all tests works fine.

The AdjustForDynamicLoad creates a configuration like this: "<openaccess><references><reference assemblyname='Links.Rubix.DataAccess.Relational' configrequired='True'/></references></openaccess>"

I can see that the problem occures when the following line of code is calles insed the ObjectContextProvider:
Database db = Telerik.OpenAccess.Database.Get("RubixConnection", xmlDoc.DocumentElement, new System.Reflection.Assembly[] { dll } );
The BackendConfiguration in the db objects gets the value: 'db.BackendConfiguration' threw an exception of type 'Telerik.OpenAccess.OpenAccessException'

Anything else I can check?

Regards
Per





0
Jordan
Telerik team
answered on 13 Jul 2010, 07:27 PM
Hi Per,

First I am sorry for the delay, but we are really busy preparing the Q2 2010 release.

Now regarding using OpenAccess model in a unit test project:

I created a simple solution that has three projects in it:
a OpenAccess model project
a console application project
a unit test project

while setting this solution up I noticed the following:
 - if the app.config file of the model project is not set to be an embedded resource the OpenAccess runtime cannot find the mapping configuration
 - it turns out that it does not matter if there is a call to the AdjustForDynamicLoad method, probably because there is a reference to the model  in the app.config file of the test project
 - in order to make the unit test project work I copied the object scope provider code and the app.config file from the console application project (that I enabled earlier with the wizard)

You can  find the solution attached.

Best wishes,
Jordan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Per
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Per
Top achievements
Rank 1
Jordan
Telerik team
Share this question
or