Ask a questionAsk a question
 

AnswerIssues using DSL Integration Service

  • Sunday, May 06, 2007 6:28 PMRui M. P. Silva Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi.

     

    I'm facing some issues using the DSL Integration Service.

     

    My goal for now is simple as referencing one instance of the minimal language (Language1) from within another instance of another minimal language (Language2). 

     

    Here the steps that i followed trying to achieve my goal:

     

    1. I've marked Language1 as exportable as you can see in the following code

     

    namespace Company.Language1

    {

    /// <summary>

    /// Double-derived class to allow easier code customization.

    /// </summary>

    /// <remarks>

    /// A package load key is required to allow this package to load when the Visual Studio SDK is not installed.

    /// Package load keys may be obtained from http://msdn.microsoft.com/vstudio/extend.

    /// Consult the Visual Studio SDK documentation for more information.

    /// [VSShell:Stick out tonguerovideLoadKey("Standard", Constants.ProductVersion, Constants.ProductName, Constants.CompanyName, 1)]

    /// </remarks>

    [VSShell::ProvideMenuResource(1000, 1)]

    [VSShell::ProvideToolboxItems(1)]

    [VSTextTemplatingHost::ProvideDirectiveProcessor(typeof(global::Company.Language1.Language1DirectiveProcessor), global::Company.Language1.Language1DirectiveProcessor.Language1DirectiveProcessorName, "A directive processor that provides access to Language1 files")]

    [global:Tongue Tiedystem.Runtime.InteropServices.Guid(Constants.Language1PackageId)]

    [Microsoft.VisualStudio.Modeling.Integration.RegisterAsExportable(

    typeof(Language1DomainModel),

    typeof(Language1SerializationBehaviorMonikerResolver),

    typeof(ExampleModel),

    typeof(Language1SerializationBehavior))]

    internal sealed partial class Language1Package : Language1PackageBase

    {

    }

    }

     

    2. In the other DSL (Language2), in the ExampleShape.OnDoubleClick() I'm implementing the following code:

     

    using System;

    using System.Collections.Generic;

    using System.Text;

    using Microsoft.VisualStudio.Modeling.Diagrams;

    using Microsoft.VisualStudio.Modeling.Integration;

    using System.Collections.ObjectModel;

    namespace Company.Language2

    {

    public partial class ExampleShape

    {

    public override void OnDoubleClick(DiagramPointEventArgs e)

    {

    // get VS DSL integration service

    IDslIntegrationService service = (IDslIntegrationService)Store.GetService(typeof(IDslIntegrationService));

    // get a domain model browser for a given dsl namespace

    IDomainModelBrowser domainModelBrowser = service.GetDomainModelBrowser("Company.Language1");

    ReadOnlyCollection<ExportedClass> x = domainModelBrowser.FindAllClasses();

    object y = domainModelBrowser.FindAllInstances(x[1]);

    base.OnDoubleClick(e);

    }

    }

    }

     

    Results:

     

    I can get a list of all the exported classes by calling the FindAllClasses() method but I can't get all instances of a given class (by calling the FindAllInstances() method)!! It always return zero elements. Any Idea?

Answers

  • Wednesday, May 09, 2007 9:29 AMEdward BakkerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    ok, sorry. I mean, when debugging Language1 (in the debug solution) I do "add new item" and select the Language2 template to create a new Language2 model in the debug solution. I add some elements to the Language2 model and save it. It is this model and the elements that are the instances I see in "y" in your example.

     

    Edward

  • Wednesday, May 09, 2007 10:34 AMEdward BakkerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Rui,

    great news! DIS reflects on the available model files (Language2.mydsl) in the current solution and gets all instances available in these model files.

     

    Edward

All Replies

  • Monday, May 07, 2007 12:00 PMEdward BakkerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

     

    I have tried your example code and it works fine in my environment. I assume in your case "x[1]" refers to the "ExampleElement" class? referencing another class might return an error because of a missing "IsElementName= true" property.

     

    Another option, does your file contain a "saved" ExampleElement? I am asking because when I first tested this I simply added an ExampleElement (shape) to the designer

    and double clicked the shape without saving the model first. X was populated fine but y (in your example) wasn't. This was obviously becuase the model wasn't saved.

     

    Edward

     

  • Monday, May 07, 2007 9:45 PMRui M. P. Silva Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Thanks Edward for your time.

     

    X[1] refers indeed to the ExampleElement class.

    By default the minimal language contains one file named Sample.mydsl which already contains two ExampleElement Shapes on it. So my target language, Language1, which resides in another DSL project solution does have a saved file called Sample.mydsl3 with two ExampleElement shapes on it.

     

    Just to make it clear I'm trying to reference a target DSL (Language1) from another DSL (Language2). These are in fact two different DSLs.

     

    For sure I'm missing something Sad

     

     

  • Wednesday, May 09, 2007 7:43 AMRui M. P. Silva Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Do you have any clue about what the problem could be?

     

    Thanks,

    Rui

  • Wednesday, May 09, 2007 8:42 AMEdward BakkerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Rui,

     

    Ok, I have tested this again, this time with two languages and everything seems to work just fine.

    Here is what I did:

     

    I created two languages: Language1 and Language2 (Language2 is exportable). In Language1 I implemented a custom command and added your code but only changed the "x[1]" to make sure it reflects the "ExampleClass" (in language 2) and changed the namespace in the "GetDomainModelBrowser" line to reflect the namespace of Language2. After that, I compiled both languages and debugged Language1. I added a Language2 to model to the Language1 debug solution and executed the custom command in Language1 (to extecute your code).

     

    For me everything works fine. Is there something you did different?

     

    Edward

     

  • Wednesday, May 09, 2007 9:04 AMRui M. P. Silva Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Edward, I don't understand what you mean with "I added a Language2 to model to the Language1 debug solution ..."?
  • Wednesday, May 09, 2007 9:29 AMEdward BakkerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    ok, sorry. I mean, when debugging Language1 (in the debug solution) I do "add new item" and select the Language2 template to create a new Language2 model in the debug solution. I add some elements to the Language2 model and save it. It is this model and the elements that are the instances I see in "y" in your example.

     

    Edward

  • Wednesday, May 09, 2007 10:02 AMRui M. P. Silva Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Finally Smile That was the piece I was missing.

     

    I was triying to reference a model that wasn't in current debug solution. Isn't this a supported scenario? I think that i some cases it would be usefull to reference some assembly with some model defined on it.

     

    Anyway for now i satisfied. Thanks Edward.

  • Wednesday, May 09, 2007 10:34 AMEdward BakkerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Rui,

    great news! DIS reflects on the available model files (Language2.mydsl) in the current solution and gets all instances available in these model files.

     

    Edward

  • Thursday, May 24, 2007 6:24 AMKishore Gopalan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I'm not able to find the Microsoft.VisualStudio.Modeling.Integration namespace. Is this part of the standard DSL Tools installed with VS SDK? Or should I add it from elsewhere?

     

    Any pointers to sample implementations of DSL Integration will be very useful.

     

    TIA

     

    Kishore

  • Thursday, May 24, 2007 8:05 AMKishore Gopalan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Got it.

     

    I guess it is the same as this. Any pointers to application samples on getting started with DIS will be very helpful.

     

    TIA

     

    Kishore

  • Thursday, May 24, 2007 10:41 PMEdward BakkerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

     

    DIS comes with a (small) document that explains how to use it. You will find it in the install directory after installing DIS on your machine. Also, you might want to have a look a this article at MSDN site that covers DIS.

     

    Edward

  • Friday, May 25, 2007 8:35 AMKishore Gopalan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

     

    I'm not able to find Microsoft.VisualStudio.Modeling.Integration assembly with the DIS instllation, and the DslPackage.csproj present in the DIS sample is not opening, gives an error - "The imported project C:\Program Files\Microsoft Visual Studio 2005 SDK\2006.09\VisualStudioIntegration\Tools\Build\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <import> declaration is correct, and that the file exists on disk"

     

    Please let me know, if I'm missing something.

     

    TIA

     

    Kishore

     

  • Friday, May 25, 2007 12:59 PMEdward BakkerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

     

    You should find the assembly in the "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies" folder. I think you are running VS SDK 4.0 on your machine, so the "2006.09" part in the imported project link should be "2007.02" you can change this manualy by opening the "DslPackage.csproj" file in notepad (for example)

     

    Hope this helps

     

    Edward

  • Thursday, May 31, 2007 3:45 AMKishore Gopalan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

     

    I have a model, with a domain property (say, P) of a domain class set to the following custom attributes.

     

    [Microsoft.VisualStudio.Modeling.Integration.TargetClass(@"CompanyName.BizModel\FlowElement")]

    [System.ComponentModel.Editor(typeof(Microsoft.VisualStudio.Modeling.Integration.Editors.ExportedClassEditor),typeof(System.Drawing.Design.UITypeEditor))]

    [System.ComponentModel.TypeConverter(typeof(Microsoft.VisualStudio.Modeling.Integration.ExportedInstanceConverter))]

     

    And it's package class is marked exportable.

     

    Code Snippet

    [RegisterAsExportable(typeof(BizModelDomainModel),

    typeof(BizModelSerializationBehaviorMonikerResolver),

    typeof(FlowGraph),

    typeof(BizModelSerializationBehavior))]

    internal sealed partial class BizModelPackage

    {

    }

     

     I run the model to open the Debudding solution. The propery P appears with a default value "mel://" and when I click on the "..." button to open the property page I get this error.

     

    Package Load Failure. Package 'Microsoft.VisualStudio.Modeling.Integration.DslIntegrationPackage,Microsoft.VisualStudio.Modeling.Integration, Version=8.2.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' had failed to load propery ( GUID ={E7A6F5A1-596D-4325-BBF5-6127A0925F72}). Please contact package vendor for assistance.

     

    I tried adding a reference to the Microsoft.VisualStudio.Modeling.Integration assembly in the Debugging solution, but of no avail.

     

    Am I missing something?

     

    TIA

     

    Kishore

  • Wednesday, July 25, 2007 12:22 PMKUCL Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

    just in case that you haven't found the problem yet.

    I faced the same problem and by using the Package Load Analyzer I figured out that The DSLIntegrationService was referring to a dll in C://WINDOWS/system32. As the folder WINDOWS doesn't exist on my machine, I changed registry settings from WINDOWS to WINNT and it works fine now.

     

    However, I'm facing another problem. The ExportedClassEditor only shows the DSL models which are part of C# projects. Since I am using my own project type (as e.g. IronPython does), all DSL files in this custom project aren't shown in the ExportedClassEditor even though they are in the same solution!!

    One more thing I have to consider in the registry??

     

    Any help is appreciated,

     

    Claudia