Pim Vendrig

Hi all,

I have a DSL, that dynamically loads an external assembly (The end-user can indicate where the DSL can find the assembly). After the DSL loads the external assembly, it creates a DomainClass that represents a class in the Assembly.
The DomainClass has some DomainProperties
- a string name
- a string namespace
- a Type type

This all works. All the properties are set correctly. When I close the DSL, the data gets serialized. When opening the DSL again, the data gets deserialized, but there is a warning. The warning sais: "Invalid property value 'AAEAAAD/////AQAAAAAAAAAEAQAAAB9TeXN0ZW0uVW5pdHlTZXJpYWxpemF0aW9uSG9sZGVyAwAAAAREYXRhCVVuaXR5VHlwZQxBc3NlbWJseU5hbWUBAAEIBgIAAAAYRGVidWdnaW5nLlBpbXNwYWNlLlBldFtdBAAAAAYDAAAASkNvbnNvbGVBcHBsaWNhdGlvbjEsIFZlcnNpb249MS4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsCw==' for property 'type' with type 'Type', ignored.

I believe this is because the DSL hasn't loaded the external assembly, and can't figure out what the Type is.
When saving and closing the DSL again, the DSL clears the DomainProperty type, and doesn't serialize it.
When opening the DSL again, there are no warning, because the type has become null.

I have tried loading the external assembly in the OnDocumentLoading in MyDslDocData:
Code Snippet

protected override void OnDocumentLoading(EventArgs e)
{
byte[] bytes = File.ReadAllBytes(@"C:\Documents and Settings\pvendrig\Mijn documenten\Visual Studio 2005\Projects\NHibernate\ConsoleApplication1\obj\Debug\ConsoleApplication1.exe");
AppDomain.CurrentDomain.Load(bytes);

base.OnDocumentLoading(e);
}

(The location of the assembly is for testingpurposes written hardcoded, the location actually is stored in a DomainProperty. So I won't be able to add the assembly as a reference, I can only load the assembly in code).

The DSL still gives the warning.
Does somebody perhaps know a way of loading the external assembly, so the DSL will recognise the Type, and won't give warnings

Thanks in advance,

Pim Vendrig


Re: Visual Studio Extensibility How to add external assembly to the DSL dynamically?

timiil

Hello Pim,

Can it possible change to :

...

The DomainClass has some DomainProperties
- a string name
- a string namespace
- a string fullTypeName //- a Type type

...

Then you may load the Type from the fullname , and just serialie the fullname,

i don't know that could or could not work for you





Re: Visual Studio Extensibility How to add external assembly to the DSL dynamically?

Pim Vendrig

Hi timiil,

Thanks for your quick reply. Your idea works, but it is kind of a workaround.

I am still looking for a way to work with Type. Is there a way of making sure the DSL knows the assembly, so it recognizes the Type I think i did it wrong in my example above.

TIA, Pim