Correct steps to add reference to external library

SyntaxEditor .NET Languages Add-on for Silverlight Forum

Posted 12 years ago by Mike Pavlov - Terrasoft
Avatar
Hello!

We wanna to buy your latest version of SyntaxEditor .NET Languages Add-on (for Silverlight), but before it we need to be shore, that we can simply add refences to external libraries for Intellisence features

According to this forum and Actinpro Silverlight Studio Documentation, I took latest version of WPF SyntaxEditor for generate type info for my libraries

First problem - I can't find any where instructions for generating type info. I tried to do this next way:
1) I opened solution of WPF SampleBrowser for VS2010 (C# version), changed framework for the project to 4.0 (after downloading your project for VS2010 where set to 3.5 framework by default)
2) Included target library to project references
3) Compiled project
4) Goto obj/Debug folder and took generated ResolveAssemblyReference.cache file

After that I included this cache file to my Silverlight project as embedded resource and in DotNetProjectAssemblyReferenceLoader(object sender, DoWorkEventArgs e) method inserted next code

var serializer = new BinaryAssemblySerializer();
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SLProjectName.ResolveAssemblyReference.cache")) {
                var assembly = serializer.LoadFromStream(null, stream);
                if (assembly != null) {
                    _projectAssembly.AssemblyReferences.Add(assembly);
                }
            }
but, my experiment was a failure - in command serializer.LoadFromStream(null, stream) I got NullReferenceException
In debugging I test, that stream variable was not null - so now i don't know - how to get correct result and where were my error

Any way - we need more flexible way to generate type info than the manual loading through WPF version of syntax editor

Comments (5)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Here's some lines of code you can use with the WPF add-on to load any .NET (non-Silverlight) assembly and generate cache files for it. For this sample we just created a new WPF project, added refs to Actipro .dlls for the add-on, and put this in the program load:
var appPath = System.IO.Directory.GetCurrentDirectory();
var cachePath = System.IO.Path.Combine(appPath, "Cache");
ActiproSoftware.Text.Languages.DotNet.Reflection.AmbientAssemblyRepositoryProvider.Repository =
    new ActiproSoftware.Text.Languages.DotNet.Reflection.Implementation.FileBasedAssemblyRepository(cachePath);
var project = new ActiproSoftware.Text.Languages.CSharp.Implementation.CSharpProjectAssembly("Loader");
project.AssemblyReferences.AddMsCorLib();
project.AssemblyReferences.AddFrom(System.IO.Path.Combine(appPath, "WpfApplication1.exe"));
The last two lines show us creating cache files for MSCorlib and the actual .exe, and they go into the bin/debug/cache folder for the app. Then you can copy those files (which are named like "mscorlib-v2.0-d7ffa534.Reflection.dat" to your SL project).

I don't think your code was working because the .cache files you used were not output by us. Those are VS files. Our files go into the cache folder you designate in the FileBasedAssemblyRepository constructor.


Actipro Software Support

Posted 12 years ago by Mike Pavlov - Terrasoft
Avatar
Correct me, if i'not right: to use and update(because libraries will be changed) references in my SL project I must buy WPF version also to generate type info? Even if I need only SL addon to work with
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Actually if you are just doing the code snippet I included above, you can reference the WPF libraries that are included with the Language Designer in the Silverlight Studio download only. That way you don't need to download WPF Studio at all.


Actipro Software Support

Posted 12 years ago by Mike Pavlov - Terrasoft
Avatar
Don't you wish to reflect all of this questions in documentation? : )
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes indeed... we've already updated our Assemblies documentation topic with the new information provided above (and more), which will be in the next maintenance release's documentation.


Actipro Software Support

The latest build of this product (v18.1 build 0233) was released 4 years ago, which was after the last post in this thread.