Can't Seem To Add System.Windows to assembly reference

SyntaxEditor .NET Languages Add-on for WPF Forum

Posted 4 years ago by Scott Jeslis
Version: 18.1.0674
Platform: .NET 4.5
Environment: Windows 10 (64-bit)
Avatar

Hello, I can't seem to add System.Windows to my assembly references and hence end up with no IntelliPrompt support for MessageBox, etc.

My load code is:

mCSharpProjectAssembly.AssemblyReferences.AddMsCorLib();
mCSharpProjectAssembly.AssemblyReferences.Add("System");
mCSharpProjectAssembly.AssemblyReferences.Add("System.Core");
mCSharpProjectAssembly.AssemblyReferences.Add("System.Windows");
mCSharpProjectAssembly.AssemblyReferences.Add("System.Xml");

After I run the above block of code my AssemblyReferences list only has 4 items CorLib, System, Core and XML.

Comments (8)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Scott,

Make sure you have Visual Studio set to break on all exceptions.  You'll probably see something like:

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Windows' or one of its dependencies. The system cannot find the file specified.'

The Add method overload you use there ends up calling Assembly.ReflectionOnlyLoad to try and load from the GAC, but it's not finding it there that way.  You might need to load the assembly another way, such as via a file path.


Actipro Software Support

Posted 4 years ago by Scott Jeslis
Avatar

Good point. I fixed that and still no IntelliPrompt for anything in the System.Windows library, e.g. MessageBox. Hmm

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Scott,

Let me give some more detail since I think you might be confusing namespaces and assemblies.  For instance, if you want WPF platform-related IntelliPrompt, you'd want to use these references to the WPF platform assemblies in addition to the normal MSCorLib, System, etc. ones:

projectAssembly.AssemblyReferences.Add("WindowsBase");
projectAssembly.AssemblyReferences.Add("PresentationFramework");

Then your C#/VB document that you are editing with our .NET Languages Add-on language in SyntaxEditor would need to import the "System.Windows" namespace at the top like you do in your own C#/VB code files.  That namespace has types like MessageBox, which are defined in those referenced assemblies.


Actipro Software Support

Posted 4 years ago by Scott Jeslis
Avatar

Just and that's exactly what I am doing. And it compiles fine, just no IntelliPrompt :-)

// calcCustomAuto1
using System;
using CIC.Framework.CustomAutomation;
using CIC.Framework.CustomAutomation.Framework;
using System.Windows;
using System.Windows.Forms;
using Newtonsoft.Json;

namespace Calculator.Calc
{
public class Calccustomauto1 : IProcessor
{
public CICHelper Helper { get; set; }

public void Initialize(string eventName, string eventValue, string stepName, string applicationName, string projectName, string projectDir)
{
var x = 1;
MessageBox.Show("In Initialize");
}

.

.

.

[Modified 4 years ago]

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Scott,

When I go into our DotNetAddonCSharpEditor demo, add the two assembly reference lines above at the end of the DotNetProjectAssemblyReferenceLoader method, run the sample, and add the "using System.Windows;" line, I see MessageBox listed in the completion lists.  Do you see the same in that sample?

If so, then perhaps you are missing some essential configuration steps for the add-on in your own app project.  Make sure you read the "SyntaxEditor / .NET Langauges Add-on / C# Language / Getting Started" topic in the documentation that comes with the controls.  You need to do all those steps or else IntelliPrompt might not function correctly.


Actipro Software Support

Posted 4 years ago by Scott Jeslis
Avatar

Okay, good to know you got it to work. Yes I've gone through that help section but will revisit again.

It's strange though that I get IntelliPrompt for other C# types like "var", "bool", etc. so IntelliPrompt is working for everything but Systems.Window for me, perplexing.

[Modified 4 years ago]

Posted 4 years ago by Scott Jeslis
Avatar

Okay so I found my issue.

In an effort to keep assembly reference cache to a minimum I only loaded System.Windows BECAUSE according to Microsoft C# documentation MessageBox is in System.Windows. It seems not to work though without also including System.Windows.Forms <sigh>.

Thanks for your help!

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Scott,

There is a MessageBox class in both WPF and WinForms.  But you shouldn't have to load anything related to WinForms to see IntelliPrompt for the WPF MessageBox if you do the steps I mentioned above.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.