How to consume external services in Dynamics 365 finance and operations - microsoft-dynamics

I am new to MS Dynamics 365 Finance and Operations application development.
I am creating a D365 F&O application where i want to consume some services for this i have written a class library. I have followed below MS steps
https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-tools/write-business-logic
I am trying to consume service in a X++ class .My code is simple,
Fullscreen
public static void main(Args _args)
{
// info(ServiceLibrary.StockQuoteClass::GetQuote("MSFT"));
info(ServicesLib.DemoService::GetTeamName("TeamName"));
}
I am getting error at main that A Reference to System.Runtime Version=5 ,Culture=Neutral ,Public Key Token="dfsdfd" required to compile this module.
I have intalled .Net 5 latest sdk.restarted visual studio but not worked?

Add a reference pointing to the DriversLIcenseEvaluator project
From this part on, it explains very clear what to do before running. I think you haven't put in this reference the right way.

Try setting the .NET framework version on your Class Library projetct to 4.6. D365 FnO runs on 4.6.

Related

ABAP Unit tests are only detected / executable right after generating. How to make the test class visible?

I'm trying to write unit tests for my class in ABAP but when I write the code manually in Eclipse, the IDE tells me there is no test class and no executable tests. If I use the wizard in SAP GUI, the generated test works and I can replace it with my test - which then also works - but when I close the SAP GUI and reopen it again, it doesn't detect any test class or executable tests again.
It seems like a bug to me or some issue with the SAP version I am using:
SAP NETWEAVER 7.4 15 (06/2016) sap.com SAP NETWEAVER 7.4
I'm a beginner ABAP programmer but I already successfully covered another one of my classes with test and I have no problems there. The only difference is that the other class runs on a different system with higher version of SAP - 7.5.
Have you encountered issue like this?
After few days of light research I found out there is a SAP Note 2598526 which pretty much describes the issue I have.
For the future reference it states that:
Reason and Prerequisites:
The ABAP unit test framework calls the class CL_ABAP_COMPILER to determine the test classes from the current program. However, the call of the class CL_ABAP_COMPILER terminates with an internal error.
Solution:
If the description applies to your situation, please install a new kernel that contains the patch "ABAP-SYCH: Dumped TYPES table has dangling type ids".
Right now we will try to patch the kernel and I will let you know if that helps.
EDIT 06/05/2019:
So... the patch didn't help with this issue but it looks like I finally found a solution. There are three steps to it:
Open SE03 and make sure the namespace is listed here with development license and in production role (P)
Open report: SATC_AC_INIT_NAMESPACE_REG and register the namespace to the ATC (ABAP Test Cockpit) - otherwise the cockpit will ignore the namespace and won't scan it for test classes.
The registration of the namespace will create a request so transport it and reactive the class that has unit tests.
When you do this, you should be able to run the tests - in both SAP GUI and Eclipse no problem :).

How to profile a test in Android Studio?

My Android app has some slow running functionality. A unit test captures it perfectly. The unit test execution shows that it runs way slower than it should be.
Android Studio keeps offering me next to the run method a menu option: "Profile" instead of run. I select that option, but nothing different than run seems to happen. I expected Android Studio to open a window with the timing of all the method calls after the test completes.
I've searched Google and the Android site. Everything I find talks about profiling in Android Studio in general.
How do I profile an Android unit test? (What does that profile option really do?)
I had the same issue and I decided to investigate a solution because I was thinking that it couldn't be too hard. Boy was I wrong.
My original answer which was never posted contained some awkward fiddling around with Thread.sleep and manual timings and hitting the right button at the right time. This was replaced by a more elegant solution using the Debug API from within the code.
Using Android Studio 3.1.3 these were my steps:
I had to copy my actual unit test into androidTest (because I actually was interested in algorithmic complexity (and not time consumption) I found no way to actually profile inside Android Studio without an emulator. For performance tests this makes sense but in my case I wanted to ensure that even in complex scenarios my methods behave in a predictable fashion.)
To avoid the need of fiddling with with Thread.sleep and log output indicating a start/stop you can use combinations of Debug.startMethodTracing("File"); or Debug.startMethodTracingSampling() and Debug.stopMethodTracing(); or similar (See https://developer.android.com/studio/profile/generate-trace-logs). My code now looks like
#Test
public void Test_Something() throws Exception
{
Debug.startMethodTracing("Predict");
// DO YOUR CODE
Debug.stopMethodTracing();
}
When I now execute the profile I can obtain the .trace generated in the mentioned location on the device as stated in the link above:
(again read the linked page because you will need WRITE_EXTERNAL_STORAGE permission, which my app already had, so it wasn't that much of a hassle in my case.
Double clicking the trace opens it in Android Studio. Unlike stated at the link above I am currently unable to import such a trace in the profiler because either 3.1.3 lacks this function or I am unable to locate it.
Edit: After I upgraded to Android Studio 3.2 I now can indeed load and save sessions and display them in the Profiler. This has improved a lot. And interesting fact: When I opened the trace in Android Studio 3.1.3 I saw the hit count for methods (how often methods were called) and not their clock times. In the profiler on the other hand I was not yet able to find the call times but instead have access to wall clock times. Would be great if someone has a hint on how to display those too.

UWP: WACK test failing on Windows Runtime metadata validation

I have a C# app targeting Windows-10 desktop platform.The C# app calls into native component written in C++. My native C++ code has Visual C++ component extensions(C++/CX).
I am trying to run WACK test for my app & I am seeing this error:
Error Found: The general metadata correctness test detected the following errors: The overloaded method XXX in yyy.winmd have the same number of in parameters without one that has DefaultOverloadAttribute. Exactly one method overload must have DefaultOverloadAttribute
Impact if not fixed: Windows store doesnt allow apps that don't pass Windows Runtime Metadata Validation.
How to fix: Please ensure that the compiler you are using to generate your Windows Runtime types is up to date with the Windows Runtime specifications
This used to work fine with VS-2015 Update 2. I installed VS-2015 Update-3 today & from then I am seeing this failure.
The strange thing is that the overloaded method mentioned in the Error Report is not overloaded at all.
I have checked this MSDN page but couldnt find any solution.
My VS details are as follows:
MS VS Professional 2015
Version 14.0.25425.01 Update 3
MS .NET Framework
Version 4.6.01038
I couldnt find any Windows Runtime Specifications anywhere. Do I need to anything additional after installing VS Update-3 ?
This seems to be a VS compiler issue. Basically WACK tool is complaining about any user defined method name "Close"
The compiler adds an IClosable implementation whenever user defined ref class has an explicit destructor. It then maps the destructor to "IClosable::Close" method. But the compiler is not complaining about user defined method named "Close".
On further digging, I found that SQLite also seem to have similar issues. This is exactly the issue which I am hitting as well.
This is the solution employed by SQLite.
After looking at the SQLite solution, I then modified my method name from "Close" to "Closedb" and now my WACK tests pass.
As of this posting the only resolution for this issue seems like not to have a method named "Close" in your code.

Upgraded java library to 1.19.0 and User model return types are all different

I'm using the Java client library for the Directory API from here:
https://developers.google.com/api-client-library/java/apis/admin/directory_v1
The com.google.api.services.admin.directory.model.User model has changed from 1.16 to 1.19.
In the old version I used to be able to do this:
List<UserAddress> userAddressList = user.getAddresses();
for(UserAddress userAddress : userAddressList) {
///
}
But now user.getAddresses is returning an Object. Same deal for getOrganizations, phones, etc... These all return an Object which upon further inspection looks like:
List<ArrayMap<String, String>>
ArrayMap extends GenericJson.
What do I have to do to get at the UserAddress, other then going back to the previous version?
It's a bug (from my point of view) in the latest versions. Use an older one like 1.16, 1.17 or the first 1.18 (latest 1.18 also have the bug).
The same thing happened in the C# client and back in May 2015 a Google developer named Eric Koleda replied:
A change to the backend had the unintended consequence of changing the discovery document for the service, making the addresses field (and others) being marked as type=any. This causes problems for strongly types languages like .NET, as you've found. The team is aware of the issue but it's unclear when a fix will be available.
However the C# client still has this problem, so I would assume the Java client does as well.
Here are a couple of issues I found in Google's issue tracker specifically for this problem in the Java client, but neither has seen any progress yet:
Issue 3645: Broken code generator for Directory API in Java client: User class lacking explicit types
Issue 3730: Latest version of the Directory API client returns Object instead of correct class

How to use SAPI's SetNotifyCallbackFunction() in a CLR project with Windows Form as the interface window?

I'm trying to write a dll plugin for Winamp. I'm using Microsoft Visual Studio 2008 and Microsoft SAPI 5.1. I created the interface window using Windows Form (System::Windows::Forms::Form).
I tried to use SetNotifyWIndowMessage(), but the method is never called when I speak to the microphone. So I tried using SetNotifyCallbackFunction(), but I got a compile error saying that I should use '&' in front of the method name in the parameter. However, when I add the '&', I got another compile error saying that i can't take the address of the method unless creating delegate instance.
What should I do? Someone please help me..
Well, as indicated, you need to create a delegate instance to wrap your callback. But don't go there, SAPI 5.1 is quite outdated. Updates are no longer shipped because the .NET framework has a very nice wrapper for it. Check out the System.Speech.Recognition namespace and the SpeechRecognitionEngine class. You'll want to use the SpeechRegonized event. You'll find plenty of code samples in the MSDN Library pages for the class.