Hi all,
I tried to search in the documentation and this community, but couldn't find the answer. Also a bit new at this (Dataminer, C# and DLLs).
I have a Protocol defining a QAction using `Skyline.DataMiner.Core.DataMinerSystem.Common`. In Visual Studio I use NuGet to import this DLL, but when I publish the protocol to Dataminer and create an Element from it, I end up with the following errors:
(42,29): error CS0234: The type or namespace name 'Core' does not exist in the namespace 'Skyline.DataMiner' (are you missing an assembly reference?) (51,29): error CS0234: The type or namespace name 'Core' does not exist in the namespace 'Skyline.DataMiner' (are you missing an assembly reference?) (139,52): error CS0246: The type or namespace name 'IDmsElement' could not be found (are you missing a using directive or an assembly reference?) (209,52): error CS0246: The type or namespace name 'IDmsElement' could not be found (are you missing a using directive or an assembly reference?) (231,59): error CS0246: The type or namespace name 'IDmsElement' could not be found (are you missing a using directive or an assembly reference?) (247,52): error CS0246: The type or namespace name 'IDmsElement' could not be found (are you missing a using directive or an assembly reference?) (76,17): error CS0246: The type or namespace name 'IDmsElement' could not be found (are you missing a using directive or an assembly reference?) (81,17): error CS0246: The type or namespace name 'IDma' could not be found (are you missing a using directive or an assembly reference?) (91,13): error CS0246: The type or namespace name 'IDms' could not be found (are you missing a using directive or an assembly reference?) (91,33): error CS1061: 'SLProtocol' does not contain a definition for 'GetDms' and no accessible extension method 'GetDms' accepting a first argument of type 'SLProtocol' could be found (are you missing a using directive or an assembly reference?) (126,17): error CS0246: The type or namespace name 'IDms' could not be found (are you missing a using directive or an assembly reference?) (126,37): error CS1061: 'SLProtocol' does not contain a definition for 'GetDms' and no accessible extension method 'GetDms' accepting a first argument of type 'SLProtocol' could be found (are you missing a using directive or an assembly reference?) (127,17): error CS0246: The type or namespace name 'IDmsElement' could not be found (are you missing a using directive or an assembly reference?) (130,108): error CS1503: Argument 1: cannot convert from 'common.TestRunner.Testdata' to 'common.TestRunner.TestdataParam[]' (132,39): error CS1579: foreach statement cannot operate on variables of type '?' because '?' does not contain a public instance definition for 'GetEnumerator' (181,17): error CS0246: The type or namespace name 'IDmsStandaloneParameter<>' could not be found (are you missing a using directive or an assembly reference?) (193,17): error CS0246: The type or namespace name 'IDmsStandaloneParameter<>' could not be found (are you missing a using directive or an assembly reference?) (213,17): error CS0246: The type or namespace name 'IDmsStandaloneParameter<>' could not be found (are you missing a using directive or an assembly reference?) (233,17): error CS0246: The type or namespace name 'IDmsStandaloneParameter<>' could not be found (are you missing a using directive or an assembly reference?) (252,17): error CS0246: The type or namespace name 'IDmsStandaloneParameter<>' could not be found (are you missing a using directive or an assembly reference?)
In my code I'm import the dll with
<QAction id="10000" name="After Protocol Startup" encoding="csharp" triggers="10000" dllImport="SLProtocolScripts.dll;Skyline.DataMiner.Core.DataMinerSystem.Common.dll;.Interop.SLDms.dll" options="precompile;dllname=OnStartup">
And then using this QAction in another QAction with `dllImport="SLProtocolScripts.dll;[ProtocolName].[ProtocolVersion].OnStartup.dll"`which is triggered by a button (just for context).
I understand that I might have to import "Skyline.DataMiner.Core.DataMinerSystem.Common.dll" onto the host machine in "C:\Skyline DataMiner\ProtocolScripts"? There are talks about a "DLLImport" directory, should I create it if it doesn't exist?
I don't seem to be able to find this DLL either? Is there a common dll library available online? Or should I dabble in NuGet configuration on the host to get the proper DLLs imported automatically? If so, where and how? (tutorial links on that are welcome).
Last question I have is regarding this error:
'SLProtocol' does not contain a definition for 'GetDms' and no accessible extension method 'GetDms' accepting a first argument of type 'SLProtocol' could be found (are you missing a using directive or an assembly reference?)
Checking the documentation (https://docs.dataminer.services/develop/devguide/ClassLibrary/ClassLibraryIntroduction.html) I see this code is valid from a QAction (which is the case). I guess the extension is not loaded or applied? How do I get/use the SLProtocolsExtensions class from the SLProtocol object?
Thank you for your answers (and sorry for the next-to-zero level).
Hi Sylvain,
If you create a protocol solution using a recent version of DIS, all you have to do is add a reference to the Skyline.DataMiner.Core.DataMinerSystem.Protocol NuGet package (this package has a dependency on the Skyline.DataMiner.Core.DataMinerSystem.Common NuGet package which contains most of the class library functionality. The Protocol NuGet package contains the extension method).
In a solution based protocol, you don't have to fill in the dllImport attribute yourself, DIS will do that automatically when publishing.
When you then publish (or save the protocol as a dmprotocol package), you should see that the dllImport attribute refers to a DllImport folder, this is where the assemblies of the referenced NuGet packages will be published (for example, skyline.dataminer.core.dataminersystem.common\1.1.1.4\lib\net462\Skyline.DataMiner.Core.DataMinerSystem.Common.dll;skyline.dataminer.core.dataminersystem.protocol\1.1.1.4\lib\net462\Skyline.DataMiner.Core.DataMinerSystem.Protocol.dll)
In a solution based protocol, when you want to use a QAction in another one, you have to add a project reference to the QAction project.
Make sure that the version of the Core.DataMinerSystem is compatible with the version of the Skyline.DataMiner.Dev.Protocol package (if not, Visual Studio should show an error message and the package will not be installed).
Another thing to be aware of is that while in Visual Studio a NuGet package reference is transitive (i.e. when adding a NuGet package to a project and then referencing this project from another project, you can use that NuGet package in the other project as well), DIS does not support this. This means that you'll also need to add the NuGet package to the other project as well.
Also check your Visual Studio options that you are not using the packages.config package management format (Tools > Options > NuGet Package Manager). Only the newer packageReference is supported. (only applicable if the QAction projects are legacy style.)