UWP: WACK test failing on Windows Runtime metadata validation - c++

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.

Related

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.

Visual Studio 2013 Profiling a Cinder project, not a single function call shows up

I recently upgraded to Visual Studio 2013, and found myself in the unusual position of suddenly needing to make use of a new aspect of VS that I've never worked with before. The profiler!
Long story short - I'm working a with a simple GUI framework I've designed, that recently had gesture support added. To my horror I found what worked more or less fine in one project, bogged down my main app quite horribly. I have a fairly good idea of what's causing it, but I'd still like confirmation - and since I will likely be working quite a bit more on the framework I'm building, it certainly doesn't help to have some profiling tools in place to remove eventual bottlenecks.
I ran the Visual studio performance wizard and was surprised to see (in the 'Call Tree' view) that the output consists of essentially nothing but calls to my TTD.exe (main application) and a bunch to ntdll.dll as well as few other DLLs I'm using.
That's fine and dandy - but I was expecting a much more granular report. As in - which of my functions were being used X percent of the time and the likes. Not a single function is mentioned anywhere...
Googling a bit, I found this particular link:
http://blogs.msdn.com/b/scarroll/archive/2005/04/13/407984.aspx
but I highly doubt that I need to use an additional server just to serve up my - possibly missing - symbols?
I'm a bit at a loss where to begin. Perhaps the issue is that I'm using Cinder and it does a bunch of stuff behind the scenes when starting up the app? To clarify - I'm not running my app from a std. main function. Cinder essentially provides a base framework called through a macro and then my app takes over via a number of setup(), draw() and update() calls. I'd just expect to see these littered all about.
But no... O_o
Has anyone encountered anything similar?
Regards,
Gazoo
You need to link your executable and DLLs with debug symbols.
In Debug builds this is on by default but in Release builds it's off by default.
Project properties->Linker->Debugging->Generate Debug Info = Yes (/DEBUG)

Can't see variable contents when debugging C++ code called from a managed app

I've got some native C DLLs which I'm calling from a Managed C++ Class library ("Rem"). In the "Rem" class library I've got one native C++ class (api) and one managed C++ class (API).
The managed class (API) is called from a C# console application for now (will be used in a web application later).
When debugging I can step through my native code just fine.
My problem is that when I'm debugging, I can't see the values of any variables other than simple types that are locally declared.
Function parameters are not available in the debugger and if I try to add them as a Watch it just says "error: identifier 'schema_name' out of scope" ('schema_name' is the variable name)
Any structs just show the value "{...}", both in the quick watch and the Watch-window.
If I try and add a watch to a field in a struct I get the value "error: 'entryList.numItems' does not exist"
Stuff I've tried:
I've tried creating a Console application in Managed C++ and debug from that, same thing.
I tried unchecking the
Tools->Options->Debugging->General->Managed C++ Compatibility Mode, then I couldn't step into the code at all (no symbols loaded for the breakpoints)
In the C# console app project, I've gone into Properties->Debug and checked "Enable native code debugging" (and unchecked it)
In the C++ class library I've gone into Properties->Debugging->Debugger Type and tried "Mixed", "Native", "Managed" and "Auto".
Any suggestions as to what I'm doing wrong?
I guess you are using Visual Studio 2012 Update 2. In that case - this is a known bug with Update 2:
https://connect.microsoft.com/VisualStudio/feedback/details/783004/children-cannot-be-evaluated-on-c-cli-after-vs2012-update-2
Be careful though, the "workaround" of uninstalling Update 2 will leave you with a broken Visual Studio as seen in this bug-report (yes, Update 2 is broken):
https://connect.microsoft.com/VisualStudio/feedback/details/785396/uninstalling-vs2012-update-2-and-repair-of-vs-results-in-atl-files-missing
In case you are not using Update 2 this might not be the correct answer but it could help others who experience exactly this problem using Update 2.

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.

RegisterClassObjects() Doesn't Find Classes To Register

I'm in the process of converting an application from Visual Studio C++ 6.0 to Visual Studio 2008 and am running into problems with ATL.
I've been having a whole host of issues, but this is the first call that differs in return values between the two different compilers.
The following line, when compiled with VC++ 6.0, returns S-OK. When running in VS 2008, it returns S-FALSE. According to the MSDN documentation, this means it couldn't find any classes to register.
_Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, REGCLS_MULTIPLEUSE)
Any help would be greatly appreciated. Thanks!
I too ran into an issue related to RegisterClassObjects returning S_FALSE unexpectedly. In my scenario, the service state was not changing from Starting to Running in a legacy C++/ATL/COM project. RegisterClassObjects was returning S_FALSE (effectively a warning message) because:
the previous developer had enabled COM (_ATL_NO_COM_SUPPORT had not been defined)
no COM objects had been defined within the *.EXE
CALL STACK
line 8192: *ppEntry was always NULL
AtlComModuleRegisterClassObjects
CAltExeModule.RegisterClassObjects
CAtlServiceModuleT.PreMessageLoop
if RegisterClassObjects did not return S_OK, then the the service state was not updated to Running
NEXT STEPS
The options available to you will depend on your situation. Why is RegisterClassObjects being called? Why are no COM objects being detected?
In my case:
I could not prevent RegisterClassObjects from being called
I did not want to disable COM by introducing the _ATL_NO_COM_SUPPORT because I did not fully understand the repercussions of making such a change on an application I knew nothing about
I did not want to modify the SDK by replacing if (FAILED(hr)) with if (SUCCEEDED(hr))
So I ensured that AtlComModuleRegisterClassObjects was able to find a valid COM object in the auto map (which is referenced by pComModule->m_ppAutoObjMapFirst)
CONTEXT
Visual Studio 2013
Windows SDK 7.1A
Active Template Library version 12.00
REFERENCES
Given that I know little about COM & ATL, I found this statement to be a real eye opener:
ATL Services are designed to serve COM objects. You failed to provide
any objects in the object map. Technically, ATL is working even better
- it detects there are no objects to serve, so there's no point in starting the service at all... The fault is yours - for using ATL in
an unsupported way. This said however, it's very simple to remove the
function call registering the objects...
[SOURCE: ATL Services and 2003]