Attribute Editor can't "see" the attribute

16 posts, 1 answers
  1. John
    John avatar
    17 posts
    Member since:
    Aug 2014

    Posted 05 Nov 2014 Link to this post

    I'm trying to add a custom attribute to the generated class' properties, but the Attribute Editor can never find the attribute although it is in the same namespace and the same assembly as the model itself. I always get the same error message: "the attribute was not resolved from any of the referenced assemblies"

    It is true both for custom attribute and the .NET-supplied like [DataContract()]

    Any ideas?


    John
  2. Boyan
    Admin
    Boyan avatar
    100 posts

    Posted 07 Nov 2014 Link to this post

    Hi John,

    This behavior is certainly not expected - the Attributes Editor should discover all custom attributes located in any of the assemblies referenced by project that hold the Telerik Data Access model as well as attributes defined in the same project.

    In order to be able to decorate a class or a property with an attribute you have to follow the steps described in this documentation article. Also as you would like to use a custom attribute you have to make sure that the assembly this attribute is located in is re-built successfully. Could please confirm that you have taken the described approach?

    If this does not resolve the issue on your side, in order to find the cause of it we would like to ask you the following: 
    1. Are there any other attributes discovered by the Attributes Editor auto-complete? The easiest way to check that is to open the Attributes Editor and start typing in the system namespace (or possibly the namespace that hold your custom attribute).
    2. What is the .net framework version you are using?
    3. Could please provide us with a list of assemblies that are referenced by your Telerik Data Access Model project?
    4. Could please give us a code-snippet with the attribute that is not properly discovered?

    I am looking forward to hearing from you. 

    Regards,
    Boyan
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
  4. John
    John avatar
    17 posts
    Member since:
    Aug 2014

    Posted 07 Nov 2014 in reply to Boyan Link to this post

    Boyan, 

    1. Once I begin typing the letter S of the System namespace, I get an error "Parse error: attribute text doesn't contain any opening or closing brackets" and the Auto-Complete is Ready. When I type "y", the status goes to "0 potential matches". I tried it with or without square brackets - same result.
    2. .NET 4.5.2
    3. Here is the complete listing:
    assemblyref://Telerik.OpenAccess.Windows
    projref://ModuleInterfaces
    projref://D3Specifics
    projref://FrameworkSupport
    assemblyref://Fasterflect
    assemblyref://Microsoft.CSharp
    assemblyref://Microsoft.Practices.Prism.Composition
    assemblyref://Microsoft.Practices.Prism.Interactivity
    assemblyref://Microsoft.Practices.Prism.Mvvm
    assemblyref://Microsoft.Practices.Prism.Mvvm.Desktop
    assemblyref://Microsoft.Practices.Prism.PubSubEvents
    assemblyref://Microsoft.Practices.Prism.SharedInterfaces
    assemblyref://Microsoft.Practices.ServiceLocation
    assemblyref://protobuf-net
    assemblyref://System
    assemblyref://System.Core
    assemblyref://System.Data
    assemblyref://System.Data.DataSetExtensions
    assemblyref://System.ServiceModel
    assemblyref://System.Xml
    assemblyref://System.Xml.Linq
    assemblyref://Telerik.OpenAccess
    assemblyref://Telerik.OpenAccess.35.Extensions
    assemblyref://Telerik.OpenAccess.40.Extensions
    assemblyref://Telerik.OpenAccess.Runtime
    4. I tried DataContract as my attempt but the idea was to use the following(it resides in the same namespace as the model - Novatech.ApplicationFramework.CDBService.Contracts):

    [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
    public class MDLFieldNameOverrideAttribute : Attribute
    {
        // See the attribute guidelines at 
        //  http://go.microsoft.com/fwlink/?LinkId=85236
        readonly string nameOverride;

        // This is a positional argument
        public MDLFieldNameOverrideAttribute(string nameOverride)
        {
            this.nameOverride = nameOverride;

        }

        public string PositionalString
        {
            get { return nameOverride; }
        }


    }
  5. Answer
    Boyan
    Admin
    Boyan avatar
    100 posts

    Posted 12 Nov 2014 Link to this post

    Hello John,

    It appears that this behavior is caused by an issue on our side. The Attributes Editor fails to load one of the assemblies referenced by the Telerik Data Access domain model project - the Microsoft.Practices.Prism.Composition assembly.

    Currently as a work-around you could remove this reference while your are decorating your model with attributes and re-add them once you are done. Genrally, it is recommended to use separate project for your domain model reducing the required references to this project. Please excuse us for the inconvenience.

    Additionally, I noticed that you have used the AttributeTargets.Property​ options. Please note that in such cases the Attributes Editor will present the attribute as a chose only for properties - it will not be shown for classes.

    If you have any more question or need any further assistance, do not hesitate to get back to us.
     
    Regards,
    Boyan
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  6. John
    John avatar
    17 posts
    Member since:
    Aug 2014

    Posted 12 Nov 2014 in reply to Boyan Link to this post

    that did the trick.

    Thank you.
  7. Boyan
    Admin
    Boyan avatar
    100 posts

    Posted 17 Nov 2014 Link to this post

    Hello John,

    I would like to inform you that a fix for this issue is expected with our next official release at the middle of December.

    Do let us know if you have more questions. 

    Regards,
    Boyan
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  8. Robin
    Robin avatar
    2 posts
    Member since:
    Mar 2012

    Posted 03 Mar 2015 in reply to Boyan Link to this post

    hey...

    not fixed in 2015 Q1!?

    Still have empty Results...
    It's showing "1 potential match" but nothing shown in listview under the input-box...

    regards,
    Robin
  9. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 06 Mar 2015 Link to this post

    Hello Robin,

    Thank you for contacting us.

    Let me confirm that there is no official release of Telerik Data Access, which addresses the problem with the Microsoft.Practices.Prism.Composition assembly. Nevertheless, the workaround suggested by Boyan here is still valid.

    Regarding the issue you are experiencing, it seems like it is not the same one. If this is the case, can you provide us with further details like .NET Framework version, a list of the assemblies referenced by the application on your side, and a code snippet of the custom attribute. With the help of this information we will be able to guide you in the decoration process.

    I am looking forward to your feedback.


    Regards,
    Doroteya
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  10. Robin
    Robin avatar
    2 posts
    Member since:
    Mar 2012

    Posted 06 Mar 2015 in reply to Doroteya Link to this post

    Hey Doroteya,
    App is a ".net class library" with 4.0 (tested 4.5 too), references assemblies are:

    "Microsoft.AspNet.Identity.Core" for inheriting User-Model from "IUser<TKey>"
    "System",
    "System.ComponentModel.DataAnnotations",
    "System.Core",
    "Telerik.OpenAccess",
    "Telerik.OpenAccess.35.Extensions"    

    Still not working, even when I try the workaround...

    Greetings,
    Robin





































  11. Boyan
    Admin
    Boyan avatar
    100 posts

    Posted 11 Mar 2015 Link to this post

    Hello Robin,

    In order to test the described scenario I obtained the Microsoft.AspNet.Identity.Core assembly by installing the respective nuget package (in case of .net framework 4.0 I just referenced it). Unfortunately I was not able to reproduce the same behavior. Is that the set-up you have on your side or are there any additional steps I need to follow?
     
    In order to help us investigate this issue could I kindly ask you to provide the following information:
    1. the exact version of Telerik Data Access that you are using?
    2. Which attribute you would like to add? Is it a custom one or is it a system one? If its a custom one, please provide its declaration.

    Additionally I noticed that you see the 1 potential match message which actually means that the Attributes Editor was able to discover an attribute that matched your filter. Could you please confirm that you are using the workflow described in this documentation article to decorate a class/property?

    I am looking forward to hearing from you.

    Regards,
    Boyan
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  12. Florian
    Florian avatar
    3 posts
    Member since:
    Jun 2015

    Posted 10 Jun 2015 in reply to Boyan Link to this post

    Hey Boyan,

    Same problem here. The attribute editor does not find any attribute (typing "Sys" already produces the following error: "the attribute was not resolved from any of the referenced assemblies"). I would like to add the [System.Runtime.Serialization.IgnoreDataMember()] attribute. The project is a "Class Library" with ".NET Framework 4.5" with the following referenced assemblies:

    System
    System.ComponentModel.DataAnnotations
    System.Core
    System.Runtime.Serialization
    Telerik.OpenAccess
    Telerik.OpenAccess.35.Extensions

     

    The workaround does not work for me, as I have no reference to said assembly.

    I am using version 2015.1.225.1 of Telerik Data Access.

     

    Regards,

    Florian

  13. Boyan
    Admin
    Boyan avatar
    100 posts

    Posted 15 Jun 2015 Link to this post

    Hi Florian,

    Using the setup you described and the latest official release I was unable to reproduce the issue you described following the steps below:
    1. create a new Telerik Data Access Class Library that contained a single class.
    2. add the references to System.ComponentModel.DataAnnotations and System.Runtime.Serialziation.
    3. re-build the project.
    4. open the Attributes Editor for a property (as the IgnoreDataMemberAttribute is not available for a class) and typed IgnoreDataMember. At this points I saw that the auto-completed indicated that there is one potential match and I was able to navigate to it with the arrows. After adding the attribute and re-saving the .rlinq file the property was successfully decorated with the attribute.

    Is that set-up correct?
    I created a sample project with the described set-up. If the issue still persists, could you please review it and see if there are any differences.

    I am looking forward to hearing from you.

    Regards,
    Boyan
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  14. Florian
    Florian avatar
    3 posts
    Member since:
    Jun 2015

    Posted 16 Jun 2015 in reply to Boyan Link to this post

    Hi Boyan,

    The steps are correct. But it still does not work for me. I have also downloaded your sample project and have the same issue with it. I see the attribute you added but cannot add new ones (with auto-completion not working as described in my first post).

    I have also tried to build the project before opening the Attributes Editor, but it does not change anything.

    I am using the following version of Microsoft Visual Studio running on Windows 8.1:

    Microsoft Visual Studio Professional 2013
    Version 12.0.31101.00 Update 4
    Microsoft .NET Framework
    Version 4.5.51641

     

    Regards,

    Florian

  15. Boyan
    Admin
    Boyan avatar
    100 posts

    Posted 18 Jun 2015 Link to this post

    Hi Florian,

    In our test environment, we have recreated the exact set-up you described. Unfortunately even then we were unable to reproduce the behavior you described. Are there any other modification in the project or in the environment set-up you think could be relevant? Could you please also attach the project file (.csproj) of the project that contains your Telerik Data Access model?

    Let me explain in a bit more detail what is happening - the Attributes Editor use reflection to read the metadata of the referenced assemblies and extract the attribute types within them. From the description you provided it appears that this reflection process is interrupted in an unexpected manner causing the issue. 
    Then using the reflected attribute types information and the user's input, the Attributes Editor actually modifies the xml located in the .rlinq file. Once this is done, the Telerik Data Access code generation kicks in and generates the actual domain classes.
     
    Based on that I could suggest you the following workaround:
    1. Open the .rlinq file as text.
    2. Notice that there is <Types> tag. In this tag you will notice that there are <DomainType> tags. In each of these there are <Property> tags.
    3. Lets suppose you have an Author class that has a Name property and you would like to apply the IgnoreDataMemberAttribute attribute from the System.Runtime.Serialization namespace. In order to do that please locate the corresponding <Property> tag as explained above. Once you located it please add as a child tag in it the following code:
    <domainCustomAttributes>
        <propertyBaseHasDomainCustomAttributes Id="36204dc7-fbee-403a-a682-728d0f686201">
            <domainCustomAttribute Id="0b29fbe7-68a9-45c2-9cbd-d02a09f77ebb" name="IgnoreDataMemberAttribute" namespace="System.Runtime.Serialization" />
        </propertyBaseHasDomainCustomAttributes>
    </domainCustomAttributes>

    Please note that you need fresh values for the guids marked in red.

    In order to make the process more visible I have attached two identical .rlinq files. One of them has a property decoreted with an attribute where as the other does not have one. You could use a tool to complere those files as text and see the exact differences I described above.

    Additionally, in order to get to the bottom of this issue and identify its cause, you could use Fusion Logs (please see this blog post as an example) to exactly pin-point which assembly has failed to load on your side.

    I hope this helps. Do not hesitate to get back to us with any further questions.

    Regards,
    Boyan
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  16. Florian
    Florian avatar
    3 posts
    Member since:
    Jun 2015

    Posted 19 Jun 2015 in reply to Boyan Link to this post

    Hi Boyan,

     

    Thanks for the background on what the Attributes Editor does. The workaround works perfectly.

    To find the cause of the problem, I have created the Fusion Logs as you suggested. I have created a ZIP containing the following files: 

    • The .csproj file of the project that contains the Telerik Data Access model.
    • A zip named "FusionLogs_filtered.zip" which contains the fusion logs I think could show the root of the problem
    • Another zip named "FusionLogs.zip" containing all log files created during my tests today.

    Since I did not find out how to attach files to a post here, I made the zip available for download here: https://dl.dropboxusercontent.com/u/20220723/Telerik_AttributeEditor.zip

    I think the most interesting log file is inside the NativeImages/MSBuild.exe folder. In the filtered Zip it's the only file in there named "System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.HTM". But I could not figure out what exactly the problem is.

    I have a few more plugins for Visual Studio installed, like RemObjects DataAbstract and JetBrains Resharper. Also, the windows installation is running in a VM, but I don't think that this is a problem.

     

    I can work with the workaround for now. But if I can be of any help to get to the bottom of the problem, let me know.

    Rergards,
    Florian

  17. Boyan
    Admin
    Boyan avatar
    100 posts

    Posted 24 Jun 2015 Link to this post

    Hello Florian,

    We are glad that the work-around provided is feasible in your situation. 

    Thank you for cooperation. It is much appreciated. As I reviewed the provided information though I was not able to correlate the issue you experience with any of the log entries.
    The Visual Designer is already deprecated as of out latest official release and our road map does not contain any effort in this direction. Please find out more on exactly what that means from this blog post. Therefore I cannot provide you with a time-frame for any Visual Designer fixes. We are sorry for the inconvenience caused.

    Should you have any further questions do get back to us

    Regards,
    Boyan
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Back to Top
DevCraft banner