Windows.UI.Xaml.dll throws exception IXamlApplicationProtected)->Initialize()); after adding resource tag "Microsoft.UI.Xaml.Controls" in app.xaml - mfc

I am trying to Modernize the existing MFC by following below steps
Created a WInUI project with Target platform version 10.0.18362.0 (Also updated to latest version)
Added following NuGet package for the above WinUI project CppwinRT, Web.WebView2, Microsoft.UI.Xaml, Win32.UI.SDK, Uwp.UI.Controls with latest version as on 29-Jul-2022
Then trying load xaml controls in MFC Extension Library after updating App.xaml in WinUI project.
<Toolkit:XamlApplication.Resources>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
</Toolkit:XamlApplication.Resources>
But stuck with exception in
template <typename D> auto consume_Microsoft_Toolkit_Win32_UI_XamlHost_IXamlApplicationProtected<D>::Initialize() const
{
check_hresult(WINRT_IMPL_SHIM(winrt::Microsoft::Toolkit::Win32::UI::XamlHost::IXamlApplicationProtected)->Initialize());
}
Unhandled exception at 0x37FFA101 (Windows.UI.Xaml.dll) in MfcApplication.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x29E0EB28, 0x00000002).
Also tried adding below instead of above
<Toolkit:XamlApplication.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Toolkit:XamlApplication.Resources>
But still stuck with exception in both Debug and Release mode.

Related

Specflow plugin failure for Visual Studio 2017

I have both VS 2015 Update 3 and VS 2017 15.7 installed on my machine. After installing new VS2017 I downloaded the specflow for visual studio 2017 to install in VS 2017 Enterprise (15.7)
I am able to build the code after I do getlatest but not when I edit. When I try to Add New Item a new feature file I am not able to do this using VS 2017 I can't see the SpecFlow feature template, or, indeed, any SpecFlow template. I get following error when I am trying to build after I edit/Add a line in the feature file -
Below is the error in .cs file for respective feature file :-
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at BoDi.ObjectContainer.NamedInstanceDictionaryRegistration.Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
at BoDi.ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath)
at BoDi.ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name)
at TechTalk.SpecFlow.Generator.UnitTestConverter.FeatureGeneratorRegistry..ctor(IObjectContainer objectContainer)
--- End of inner exception stack trace ---
t System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at TechTalk.SpecFlow.Generator.TestGeneratorFactory.CreateGenerator(ProjectSettings projectSettings)
at TechTalk.SpecFlow.VisualStudio.CodeBehindGenerator.Actions.GenerateTestFileAction.GenerateTestFile(GenerateTestFileParameters opts)
specflowvisual-studio-2017
Others in my team are able to build the latest code as well as they are able to edit feature file and build it successfully. How do I fix this issue on my local? I don't see any other updated version of SpecFlow where this issue got fixed. Please advise.

error during VS Debugging but no error when run exe file directly

I have a very simple c++ sample project that basically just logs in to a 3rd party library (collection of .lib files)
There are 4 provided configurations md,mdd,mt,mtd. All x64.
I can build in mdd mode and run the Exe file directly, and the program works fine.
But if I run the debugger in VS, the 3rd party library throws a runtime Exception "vector deleting destructor".
try
{
engine = new Engine(&params);
}
catch (XxxException& Ex)
{
return (ERROR);
}
Exception thrown at 0x00007FFA52003FB8 in Sample.exe: Microsoft C++ exception: XxxException at memory location 0x000000224C53F190.
Exception thrown at 0x00007FFA52003FB8 in Sample.exe: Microsoft C++ exception: XxxException at memory location 0x000000224C53F690.
0x00007ff75d5ab3e0 {Sample.exe!const XxxException::`vftable'} {0x00007ff75d2d8a50 {Sample.exe!XxxException::`vector deleting destructor'(unsigned int)}}
So I am unable to debug.
What is this error, and why does it only occur in VS Debugger?
The solution was to change the working directory as specified in Debugging from $(ProjectDir)
to $(TargetPath), where the exe was sitting!
isn't C++ a wonderful artifact of history!

OCCI app crashes when running in debug mode in Visual Studio 2005

I'm attempting to get a development environment up and running for developing applications with Oracle C++ Call Interface (OCCI) in Visual Studio 2005.
My system specs are:
OS: Windows 7, 64-bit
Oracle: 11g release 11.2.0.2, 32-bit
Instant Client: BasicLite and SDK version 11.2.0.4 32-bit
Visual Studio 2005 Professional Edition version 8.0 with 32-bit tools enabled
I've followed this guide by Mark Williams and I got the example running but only in release mode. When I switch to debug mode the app will build, but when I run it I get the following error:
Problem signature:
Problem Event Name: APPCRASH
Application Name: OCCITest.exe
Application Version: 0.0.0.0
Application Timestamp: 53f5dfdd
Fault Module Name: KERNELBASE.dll
Fault Module Version: 6.1.7601.18229
The small example program that triggers this error is:
#include "employees.h"
using namespace std;
using namespace oracle::occi;
int main (void)
{
Employees *pEmployees = new Employees();
delete pEmployees;
return 0;
}
Employees::Employees()
{
user = "hr";
passwd = "hr";
db = "localhost:1521/service_name";
env = Environment::createEnvironment(Environment::DEFAULT);
try
{
con = env->createConnection(user, passwd, db);
}
catch (SQLException& ex)
{
cout << ex.getMessage();
exit(EXIT_FAILURE);
}
}
Employees::~Employees()
{
env->terminateConnection (con);
Environment::terminateEnvironment (env);
}
If I remove all calls to OCCI functionality the application doesn’t crash. That is, this program runs error-free:
#include "employees.h"
using namespace std;
using namespace oracle::occi;
int main (void)
{
Employees *pEmployees = new Employees();
delete pEmployees;
return 0;
}
Employees::Employees()
{
user = "hr";
passwd = "hr";
db = "localhost:1521/service_name";
cout<<"Look at me, I'm running"<<endl;
}
Employees::~Employees()
{}
In the guide Mark mentions that when running in debug mode, the linker should use the library file oraocci11d.lib. However, this file is not included in the Instant Client SDK version 11.2.0.4, so I’m using the input file oraocci11.lib for both the release and debug version.
I'm running out of ideas about how to proceed in solving this problem, and I would greatly appreciate any and all help.
If the Oracle DLL receives and/or passes objects such as std::string or any other object that either:
Manipulates the heap in any way, or
The objects could have differing internals between app and DLL,
then you have no choice but to use the correct library to link with. Otherwise you wind up with binary or heap incompatible objects being passed, which leads to what you're seeing now.
See here: http://docs.oracle.com/cd/E11882_01/appdev.112/e10764/install.htm#CBHGBBJI
The link above mentions both the debug import library and debug version of the DLL. Also this is stated at the link:
Applications that link to MSVCRTD.DLL, a debug version of Microsoft C-Runtime, /MDd compiler flag, should link with these specific OCCI libraries: oraocci11d.lib and oraocci11d.dll.
Since it took me quite some time to get the debug environment working I figured I'd answer my own question now that I did.
I got a variety of errors throughout the ordeal, but the error that I got most stuck on was an error saying:
'The application was unable to start correctly (0xc0150002).
Click OK to close the application.'
Also, I used http://www.dependencywalker.com which repeatedly told me that either oraocci11d.dll or a the following list of dll's could not be found.
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL
DCOMP.DLL
IESHIMS.DLL
However, what was really missing was for the executable to be able to find oci.dll. I'm just mentioning the errors in case someone else runs into these.
Here is what was needed to make it work:
First of all, the Instant Client does not contain the oraocci11d.lib or oraocci11d.dll, so it is necessary to install the full Oracle Client.
Next, the following must be added to the PATH:
C:\Program Files\Oracle\11.2.0\OCI\lib\MSVC\vc8
C:\Program Files\Oracle\11.2.0\BIN
In Visual Studio, select Tools -> Options, unfold 'Projects and Solutions' and select VC++ Directories. In 'Show directories for' under:
Include Files add C:\Program Files\Oracle\11.2.0\OCI\include
Library files add C:\Program Files\Oracle\11.2.0\OCI\lib\MSVC\vc8
In the property page for your project under Configuration Properties -> Linker select Input and under Additional Dependencies add oraocci11d.lib (or oraocci11.lib for release mode). Then select debug/release mode in the Configuration Manager
I have a related problem in that I am successfully using oraocci12d.dll/msvcr100d.dll, but this in turn is using oci.dll/msvcr100.dll. ie, oci.dll is not using the debug version of msvcr100.
My program seems to run okay, but any memory leak reporting disappears on exit.

Using SpriteBatch with Direct3D and XAML

I have created a project that runs on Windows Phone 8 that uses the template Direct3D With XAML provided by the Windows Phone SDK. I have also incorporated DirectXTK and declared a std::unique_ptr<DirectX::SpriteBatch> m_SB; in the CubeRenderer.h
When I try to assign it in the function CreateDeviceResources thus:
m_SB.reset(new SpriteBatch(m_d3dContext.Get()));
it gives the error: An unhandled exception of type 'System.AccessViolationException' occurred in Unknown Module.
I do not know why this is. This works perfectly if I create the project with the Direct3D (Native) template.
Any help would be appreciated.
You have to put the code inside the CreateWindowSizeDependentResources function, then it should work fine.
Source

Is there a simpler Windows C++ Subversion API or an example .vcproj for minimal_client.c?

Following on the tails of my previous (answered) question...
SharpSvn makes calling the Subversion client API simple:
SvnClient client = new SvnClient();
client.Authentication.DefaultCredentials = new NetworkCredential(username, password);
client.CheckOut(new Uri("http://xxx.yyy.zzz.aaa/svn/repository"), workingCopyDir);
On the other hand, calling the client API from C/C++, as shown in minimal_client.c requires coding "closer to the metal", as it were, on Subversion.
Are there Windows libraries for C++ in Visual Studio 2003 that present a simpler interface than what minimal_client uses?
If there are not, is there a VS2003 C++ project (a .vcproj file) that demonstrates getting minimal_client to run? I'm able to compile minimal_client.c and link it using the following libraries:
libsvn_client-1.lib libsvn_delta-1.lib libsvn_diff-1.lib libsvn_fs-1.lib libsvn_fs_base-1.lib libsvn_fs_fs-1.lib libsvn_ra-1.lib libsvn_ra_local-1.lib libsvn_ra_svn-1.lib libsvn_repos-1.lib libsvn_subr-1.lib libsvn_wc-1.lib libapr-1.lib libaprutil-1.lib xml.lib libneon.lib
but when I run my application (in the debugger or start the release build without debugging), it runs for about 20 seconds without hitting the first line of main() and then throws this exception:
An unhandled exception of type
'System.TypeLoadException' occurred in
Unknown Module.
Additional information: Could not load
type apr_pool_t from assembly
minimal_client,
Version=1.0.3477.16033,
Culture=neutral, PublicKeyToken=null.
I've tried various combination of libsvn_.lib and svn_.lib to no avail.
Any thoughts on what I'm doing wrong?
EDIT: I started fresh with a "Win32 Console Project" (still in VS2003) and I am now able to debug the first few lines of my app. But now, on this line:
if (svn_cmdline_init ("minimal_client", stderr) != EXIT_SUCCESS)
I get a different exception (in the debugger or start the release build without debugging):
Unhandled exception at 0x7c91b21a in
Win32ConsoleProject_minimal_client.exe:
0xC0000005: Access violation writing
location 0x00000010.
EDIT: This thread explains that this error is a CRT mismatch between svn and stderr in my app. If I don't want to build Svn so they match (I don't want to), I can pass NULL instead of stderr (provided I'm willing to do without messages that would go to stderr) When I did this, my app ran all the way through correctly.
It seems that C++ wrappers are not overflowing the 'net. However, you may want to try SVNCPP, which can be yoinked from RapidSVN.
See http://rapidsvn.tigris.org/ for details (note: I've not tried it).
Can you upgrade to Visual C++ 2005 ? If so, you could just go using SharpSvn with C++/CLI.
Or even maybe stick to VC2003 and go SharpSvn with Managed C++ ? (not that I have any knowledge on the how od even the if)
edit: oh well, SharpSvn's homepage explicitely states that VC++ 2005 SP1 is required...