Author Topic: TargetFramework netstandard2.1 or net5.0?  (Read 6863 times)

BaslimJubbul

  • Newbie
  • *
  • Posts: 5
TargetFramework netstandard2.1 or net5.0?
« on: September 28, 2021, 05:04:41 PM »
I'm writing my first plugin, but I'm an experienced c# and DotNet developer. I can get a basic plugin working with TargetFramework=net4.8, but I have some utility code (logging, configuration, etc.) that requires a TargetFramework of either netstandard2.x or net5.0. I can successfully build the plugin with a TargetFramework of netstandard2.1, but the plugin then does not write its initialization message, nor does it appear in the plugin manager. So I thought I'd ask if this is expected? I have to use a desktop TargetFramework when building a plugin?

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2831
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #1 on: September 28, 2021, 05:58:23 PM »
VoiceAttack currently requires plugins to be written in .Net Framework 4.7.2, and will not work with .Net Standard or .Net Core:  https://dotnet.microsoft.com/download/dotnet-framework/net472

Hope that helps!
« Last Edit: October 15, 2021, 11:52:38 PM by Gary »

BaslimJubbul

  • Newbie
  • *
  • Posts: 5
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #2 on: October 15, 2021, 11:25:03 PM »
thank you! FWIW, I am now using Visual Studio Code, C#, and dotnet build / publishing my plugin with `TargetFramework=net4.8`and `Configuration=Debug`. It took a while and some simple PowerShell scripting, but (so far), I am having no problems with getting VSC to publish the .dll files to the VA Apps dir, starting VA, and attaching the Debugger to my plugin. Whee!

Robertsmania

  • Newbie
  • *
  • Posts: 46
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #3 on: February 06, 2022, 02:03:29 PM »
VoiceAttack currently requires plugins to be written in .Net Framework 4.7.2, and will not work with .Net Standard or .Net Core:  https://dotnet.microsoft.com/download/dotnet-framework/net472

Hope that helps!

I'm trying to get started with the sample C# solution and am a little confused.

When I open it in Visual Studio 2022, I get the dialog box shown in the attached image.  None of the options let me proceed with the old framework.

Selecting the download radio button takes me to a page that includes the 4.7.2 developer pack Gary links above.  I've installed that but it doesnt change the behavior.

I seem to have no option other than to update to 4.8.  Or is there an alternative?  Do I need to use and older version of Visual Studio?


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #4 on: February 06, 2022, 02:11:13 PM »
Visual Studio 2022 dropped support for certain older versions of the .NET framework which were still supported by Visual Studio 2019.
The oldest version supported by the former is 4.6.2

For the moment you could try editing VATestPlugin.csproj and changing
Code: [Select]
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>to
Code: [Select]
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>

Robertsmania

  • Newbie
  • *
  • Posts: 46
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #5 on: February 06, 2022, 06:57:19 PM »
Thank you.  Modifying the target framework version in the project file does let it load without complaint.  I'll spend some time going through the sample now that I can build and debug it.

My real goal is going to be to build a new plugin .dll in C++ rather than C#/VB.  I have an application already written in C++ and want to get its features in a voice attack plugin.  I've started doing just the naïve steps of adding a new C++/DLL project in the VATestPlugin solution but I suspect I'm missing significant steps in terms of telling that DLL to support a .Net target platform at all. 

Are there any tips or guidance for doing a VoiceAttack plugin in C++?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #6 on: February 06, 2022, 07:34:46 PM »
It should be possible to call C++ functions using System.Runtime.InteropServices, as shown here.


Plugins are beyond the advanced native functionality of VoiceAttack itself. Having a plugin interface with non-managed resources is even further beyond that.

Depending on the complexity of your C++ application, you may want to consider porting it to C# instead.

Robertsmania

  • Newbie
  • *
  • Posts: 46
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #7 on: February 06, 2022, 11:32:20 PM »
I hear that loud and clear, and it may come to that.

After spending some time with the C# samples, I do think I get the gist of it.

I did find that Visual Studio 2017 does have .Net Target Framework v4.0 that I can apply to my C++ DLL project.

As far as building a C++ class that implements the VAPluginClass required methods, its all pretty straight forward except for the dynamic vaProxy parameter.  I'm having a hard time getting my head around how to deal with that in C++.  The documentation mentions prior to version 4 there being a bunch of parameters and perhaps that would be easier to handle?  I'm exhausted now but will spend some time looking into that in the morning.

Here's what I came up with so far, but of course it doesnt compile with the undefined dynamic parameters...

Code: [Select]
#include <string>
#include <combaseapi.h>
#include <atlstr.h>

#pragma once
using namespace std;

ref class VAPluginClass {
public:

static bool _stopVariableToMonitor = false;

static string VA_DisplayName() {
return "My VoiceAttack C++ Plugin - v0.0.13";
}

static string VA_DisplayInfo() {
return "My VoiceAttack Plugin\r\n\r\nThis is just a sample.\r\n\r\n2016 VoiceAttack";  //this is just extended info that you might want to give to the user.  note that you should format this up properly.

}

static GUID VA_Id() {
GUID guid;
CString guid_str = "{E0689CF7-A25A-44C7-9894-A66354E2255C}";
HRESULT hr = CLSIDFromString(guid_str.GetBuffer(),(LPCLSID)&guid);
return guid;
}

static void VA_StopCommand() {
_stopVariableToMonitor = true;
}

//public static void VA_Init1(dynamic vaProxy)
static void VA_Init1(dynamic vaProxy) {
}

//public static void VA_Exit1(dynamic vaProxy)
static void VA_Exit1(dynamic vaProxy) {
}

//public static void VA_Invoke1(dynamic vaProxy)
static void VA_Invoke1(dynamic vaProxy) {
}
};

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #8 on: February 07, 2022, 09:07:16 AM »
The old plugin interface still works for backward-compatibility, however it is not really intended for use with new projects.

If you insist on using that, one of the rollback version .zip archives pre-v1.6 when the v4 interface was introduced (E.G. listed in this release topic) should include examples for it.

Robertsmania

  • Newbie
  • *
  • Posts: 46
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #9 on: February 07, 2022, 03:44:25 PM »
Thank you for your help and apologies for hijacking this thread away from the initial topic.

I've looked into it enough to convince myself trying to stick with C++ is going to be a nightmare.

It will be easier to switch to C# and go from there.

Robertsmania

  • Newbie
  • *
  • Posts: 46
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #10 on: February 14, 2022, 12:53:16 PM »
VoiceAttack currently requires plugins to be written in .Net Framework 4.7.2, and will not work with .Net Standard or .Net Core:  https://dotnet.microsoft.com/download/dotnet-framework/net472

Hope that helps!

Are there plans to update the target framework for Voice Attack Plugins?

There are contemporary resources I would like to reference in my solution, but get the following error.

Code: [Select]
Error Project '..\irsdkSharp-main\src\irsdkSharp\irsdkSharp.csproj' targets 'netstandard2.1;net5.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.0'. VATestPlugin

I'm currently using Visual Studio 2019 which seems happy to work with the v4.0 framework in the plugin sample.  Changing to 4.7.2 does not fix it.

This is all pretty new to me and I did the naïve approach of adding the project for the resource I want, then adding a reference to it.  Those steps go fine, but the error comes up when attempting to build.

Is there another way to access things in netstandard2.1;net5.0 from a v4.0 or 4.7.2 project?

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2831
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #11 on: February 14, 2022, 01:02:02 PM »
There is no plan in place at the moment, however, there will be a need to move beyond .Net Framework 4.7.2 (and 4.8).
 This will either require a complete rewrite of the current codebase (as plugins run in the same space as VA), or provide a completely separate process to handle interaction between VA and plugins.

Robertsmania

  • Newbie
  • *
  • Posts: 46
Re: TargetFramework netstandard2.1 or net5.0?
« Reply #12 on: February 14, 2022, 03:14:50 PM »
Okay, thank you. 

For the time being, I can do what I need with an older wrapper for the iRacing SDK that is also v4.0.  But there are some nice features in the current version that are attractive.

I do want to say THANK YOU for providing the framework for plugins in the first place.  Is amazing.  I'm new to C# and it did take me a few days to get the routines I had in C++ working properly in my plugin, but now that they are I'm so happy with how it runs.

In the past I used VoiceAttack to send keystrokes to iRacing and just hoped for the best.  It had no idea if the commands got through or did what was intended.  Being able to have two way communication between the game and VA is a game changer.  Now I can query the simulation and know whether an operation is even possible and let the user know, or have confidence that it is valid and will work.