Expression Blend + Sketchflow - Addin? - c#

Has anyone been able to get an extension up and running Expression Blend + Sketchflow preview? I'm looking for an example project.
I was following this article, but it is a bit outdated.
So far I:
Created a .Net 4.5 class library project
Added a reference to the Microsoft.Expression.Extensibility.dll in the new Blend Preview directory
Set my project to deploy to the appropriate Addins directory
Setup Visual Studio to run the new Blend.exe for debugging
Hooked up MEF and inherited IPlugin as in the example
But my plugin doesn't seem to load and no breakpoints are hit.

After reading your question I decided to start working on a new version of that tutorial.
A few things to get you started right away.
I've created the basic plugin like this:
using System.ComponentModel.Composition;
using Microsoft.Expression.Extensibility;
namespace Demo.Extension
{
[Export(typeof (IPackage))]
public class Demo : IPackage
{
public void Load(IServices services)
{
}
public void Unload()
{
}
}
}
Make sure you:
place the plugins in ...\Blend Preview\extensions
run visual studio as administrator to be able to deploy to that folder during debug
implement the IPackage instead of IPlugin

Got it working by following the demo here.
I used the few modifications above, and put things in the Blend Preview directory.

Related

Managed Package Framework for Visual Studio 2017

I'm following this tutorial on how to create a new Visual Studio Project type. In there, it says to "Import the source-code files for the Managed Package Framework". Google led me to this link that has a link to MPF 2013 package. In the first link they say to look for a file ProjectBase.files which does not exist in the second link download.
Questions:
Where is the correct MPF download for Visual Studio 2017.
In the future when we move on to Visual Studio 2019, will I need to download a new MPF for 2019?
I had the same problem, but it seems that I alreasy solved it. It seems that MPF is not needed anymore to do these steps and the tutorial is a bit outdated:
How to do it now:
Instead of loading the "Managed Package Framework code", skip this whole step in the tutorial and go to the next chaprer.
In the next chapter skip everything until step 3 and register
this.RegisterProjectFactory(new SimpleProjectFactory(this));
in the InitializeAsync Task of the SimpleProjectPackage.cs
At step 6 implement FlavoredProjectFactory instead of ProjectFactory
Continue the tutorial and it should work fine now.
In the end it should look like this:
class SimpleProjectFactory : FlavoredProjectFactory
{
private SimpleProjectPackage simpleProjectPackage;
public SimpleProjectFactory(SimpleProjectPackage simpleProjectPackage)
{
this.simpleProjectPackage = simpleProjectPackage;
}
protected override object PreCreateForOuter(object outerProject)
{
return null;
}
}

Visual Studio 2017 publish ASP.NET Core app with C# 7.2

I have a Asp.Net MVC Core website that's using public static async Task Main(). For that to work I've set the language version to C# 7.2 (in the properties -> build -> advanced dialog, double checked in the csproj) for both Debug and Release build configurations.
App builds and starts fine in both Debug and Release mode.
Now, I'm trying to publish it to an Azure Website directly from Visual Studio 2017 15.5.2 (with WebDeploy) and I get this:
Program.cs(17,29): Error CS8107: Feature 'async main' is not available
in C# 7.0. Please use language version 7.1 or greater. CSC(0,0): Error
CS5001: Program does not contain a static 'Main' method suitable for
an entry point
In the output window I see it's running C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\csc.exe with some flags, probably one of them is wrong?
Anyone know if this is a known issue or I'm doing something wrong?
This appears to be a bug in Visual Studio.
Adding this line to main property group in the .csproj file resolved the issue for me:
<LangVersion>latest</LangVersion>
The issue was also reported here in the ASP.NET Home repository.
Not an answer, per se, but for what it's worth async Main is just syntactic sugar. Behind the scenes Roslyn just adds the standard void Main wrapper construction:
static void Main(object[] args)
{
MainAsync(args).GetAwaiter().GetResult();
}
static async Task MainAsync(object[] args)
{
// your code
}
It's probably not worth your time trying to get the server on the same page C# version-wise, just to save literally three lines of code.

Are there any dependencies for UI Automation?

I have a Windows application which captures the details from screen based on the configuration. I am using UI Automation to capture the details from the screen. Everything works fine on the developer's machine where Visual Studio is installed. When I run the same application on another system where we have only .NET Framework 4.5 installed, it started behaving strangely, and it's not able to detect the child element.
My question is why it works fine on the developer's machine where Visual Studio and .NET Framework are installed. What's the difference? Is there anything we are missing as far as prerequisites? Any dependencies of UI Automation or any library we are missing..?
Thanks in advance - please help me out.
It looks like a known bug in .NET wrapper around native UIAutomationCore.dll (yes, its core is not a .NET). And it's included into WinVista+ (.NET Framework also adds it even to WinXP).
Here is a C# example how to use native COM API (UIAutomationCore.dll) from C#. Just copying the code here:
using System;
using interop.UIAutomationCore;
namespace PrintDesktopUiaElementNameViaCom
{
class PrintDesktopUiaElementNameViaComProgram
{
static void Main(string[] args)
{
// Instantiate the UIA object:
IUIAutomation _automation = new CUIAutomation();
// Get the root element
IUIAutomationElement rootElement = _automation.GetRootElement();
// Get its name
string rootName = rootElement.CurrentName;
Console.WriteLine(
"The root automation element's name should be 'Desktop'.");
Console.WriteLine("The actual value is: '{0}'", rootName);
}
}
}
Yeah at last after doing day's reading, i came to know the solution is that der is no dependency on Visual studio.
This behavior is due to lack of privileges to the application. so to overcome this behavior we have to get signed our application and one more thing its very important thing is place your executable file in Program Files
Reference Links : https://msdn.microsoft.com/en-us/library/windows/desktop/ee671610(v=vs.85).aspx

Static class not available in certain other classes

I apologise for this - it's an idiot question and I hate myself for asking it, but I can't figure out a reason for this behaviour.
I have a namespace which contains a mixture of static and non-static classes.
namespace MyNameSpace.UI.Helpers
{
public static class OrderHelper
{ // static methods
}
}
namespace MyNameSpace.UI.Helpers
{
public class CountToCampaignConverter : IMultiValueConverter
{ // non-static methods
}
}
These being helper classes, they're used throughout the application. In this class:
using MyNameSpace.UI.Helpers;
namespace MyNameSpace.UI.ViewModels
{
public class QuickCountViewModel : BaseViewModel
{
private void BuildOrderExclusionsOnCount()
{
CurrentAvailability.OrderExclusions = CountHelper.BuildOrderExclusionAsCsv(ordersToExclude);
}
}
}
However in this class:
using MyNameSpace.UI.Helpers;
namespace MyNameSpace.Service.Services
{
public class FulfillJobs : BaseService
{ // stuff
}
}
When I try to use my helpler classes, I've got access to the non-static ones, but none of the static ones.
I can't see any naming clash here - if that were the problem, surely I wouldn't be able to get the non-static ones either?
So where else can I look to resolve the issue?
This is an old post, but no fix was discovered and this issue just happened to me. Here's my particular scenario and the resolution.
I had a Visual Studio 2019 C# solution with two projects: a .NET Standard 2.0 class library and a .NET Core 3.1 console app that used the library. Everything worked fine until I changed the library from .NET Standard 2.0 to 2.1. Afterward, new static items (classes, properties, methods) defined in the library would not be recognized in the app or Visual Studio. If I reset the library back to .NET Standard 2.0 then the static items became visible, but that was not a viable solution for me.
To solve the problem, I set the library's target framework back to .NET Standard 2.1. Then I opened the app project's Reference Manager (Solution Explorer > App Project > Dependencies (right click) > Add Project Reference). I cleared the existing reference to the library and clicked OK. Then I repeated the process, but restored the reference to the library. Suddenly, the app and Visual Studio recognized all the new static items in the library.
The reason is because in the second sample, the class is in a different namespaceMyNameSpace.Service.Services.
If you add a "using" for the namespace MyNameSpace.UI.Helpers in your file, it will be visible.
You can also reference your class as UI.OrderHelper from your services, since both share the root "MyNamespace".

What are the Steps needed to use NUnit?

I Developed a small Application in C#. I want to test my application with NUnit.I am a new to NUnit.I Installed NUnit but don't Know How to use it what are the basic steps needed for it or please provide me a good reference link about using NUnit.
Check out the NUnit quick start:
Let’s start with a simple example.
Suppose we are writing a bank
application and we have a basic domain
class – Account. Account supports
operations to deposit, withdraw, and
transfer funds.
I recommend you to have an own project for your tests (like Project.Tests).
Place the following basic files somewhere in folder of your project structure (e.g. lib\nunit\nunit):
nunit.core.dll
nunit.core.interfaces.dll
nunit.framework.dll
nunit.util.dll
nunit-console.exe
nunit-console.exe.config
nunit-console-runner.dll
nunit-console-x86.exe
nunit-console-x86.exe.config
Then you need to reference the NUnit.Framework assembly in your Project.Tests project.
For example, a simple test would look like this:
using NUnit.Framework;
namespace Project.Tests
{
[TestFixture]
public class MyTestClass
{
[Test]
public void MyTestMethod()
{
var a = "a";
var b = "a";
Assert.AreEqual(a, b);
}
}
}
You can run this test then for example with the NUnit-console or directly in VisualStudio (e.g. with the help of ReSharper) or through a MSBuild task with the help of MSBuild Community Tasks.
If you don't use resharper I recommend you to use this plugin - http://www.testdriven.net/ .

Categories