Exception thrown in SurfaceImageSource.as() - directx

I'm back to C++ after a 31-year absence and have spent the last few months learning everything I can about Windows app development, UWP, C++/WinRT, DirectX, WinUI 3, XAML, etc. All within Visual Studio 2022 Community.
I'm currently working on creating an app template that brings together DirectX and WinUI 3, allowing me to draw on a surface within XAML/UI3. So far I've been able to create separate apps with each component (modifying existing Microsoft templates), but I'm struggling a bit bringing them all together.
The closest example I've found (using C++/WinRT) is the "DirectX and XAML interop" tutorial. I copied the example into my WinUI 3 project and it compiles no errors and the UI runs fine until I click on the button that invokes the tutorial code. Then it crashes trying to create a winrt::com_ptr to the SurfaceImageSource. I've spent a couple of days now trying to figure out why. The code in question is :
(C++/WinRT)
SurfaceImageSource surfaceImageSource( 500, 500 ) ;
winrt :: com_ptr <::ISurfaceImageSourceNativeWithD2D> sisNativeWithD2D {
surfaceImageSource.as <::ISurfaceImageSourceNativeWithD2D> () } ;
If I replace "surfaceImageSource.as" with "surfaceImageSource.try_as" the call returns, but .get() on the com_ptr returns nullptr. So it looks like internally, QueryInterface is not succeeding.
Any help with this would be greatly appreciated since I don't know where to go from here.
Thanks.
*** EDIT *** : additional information added per IInspectable's comment
Thanks IInspectable for your help. I can reproduce this with the following minimal setup :
1 - Create a new project from "Blank App, Packaged (WinUI 3 in Desktop)" C++/WinRT template. This project creates a blank window with a UI3 "Click Me" button in its center.
2 - In the file "MainWindow.xaml.cpp" :
a - at the top, add :
#include <windows.ui.xaml.media.dxinterop.h>
#include <winrt/Microsoft.UI.Xaml.Media.Imaging.h>
using namespace winrt::Microsoft::UI::Xaml::Media::Imaging;
b - further down, in the method "MainWindow::myButton_Click()" add the two lines mentioned earlier :
SurfaceImageSource surfaceImageSource(500, 500);
winrt::com_ptr <::ISurfaceImageSourceNativeWithD2D> sisNativeWithD2D{
surfaceImageSource.as <::ISurfaceImageSourceNativeWithD2D>() };
3 - that's it. Rebuild and the program crashes on the button click.
I put a breakpoint between the two lines above.
I then put another breakpoint in "Generated Files\winrt\base.h" on first line of "struct IUnknown :: as()":
template <typename To>
auto as() const
{ (breakpoint here)
return impl::as<To>(m_ptr);
}
When I continue execution, the program crashes immediately before returning to the next line of myButton_Click() (as far as I can determine).
Debug Output
'My_WinUI_3_project_4.exe' (Win32): Loaded 'C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.1_1004.584.2120.0_x64__8wekyb3d8bbwe\Microsoft.DirectManipulation.dll'.
onecoreuap\windows\frameworkudk\dxprivatescommon.cpp(53)\Microsoft.Internal.FrameworkUdk.dll!00007FFFABE09BC5: (caller: 00007FFFABE5ED0D) ReturnHr(1) tid(2508) 80004002 This interface is not supported
onecoreuap\windows\frameworkudk\dxprivatescommon.cpp(53)\Microsoft.Internal.FrameworkUdk.dll!00007FFFABE09BC5: (caller: 00007FFFABE5ED0D) ReturnHr(2) tid(2508) 80004002 This interface is not supported
onecoreuap\windows\frameworkudk\dxprivatescommon.cpp(53)\Microsoft.Internal.FrameworkUdk.dll!00007FFFABE09BC5: (caller: 00007FFFABE5ED0D) ReturnHr(3) tid(3670) 80004002 This interface is not supported
'My_WinUI_3_project_4.exe' (Win32): Loaded 'C:\Windows\System32\cabinet.dll'.
'My_WinUI_3_project_4.exe' (Win32): Loaded 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\XamlDiagnostics\x64\WinUI3\Microsoft.VisualStudio.DesignTools.WinUITap.dll'.
Microsoft.UI.Xaml.dll!00007FFF8DAF3D45: (caller: 00007FFF90651CAF) ReturnHr(1) tid(2508) 80070057 Incorrect parameter.
Microsoft.UI.Xaml.dll!00007FFF8DAF3D45: (caller: 00007FFF90651CAF) ReturnHr(2) tid(2508) 80070057 Incorrect parameter.
Microsoft.UI.Xaml.dll!00007FFF8DAF3D45: (caller: 00007FFF90651CAF) ReturnHr(3) tid(2508) 80070057 Incorrect parameter.
Exception thrown at 0x00007FF83C644FD9 (KernelBase.dll) in My_WinUI_3_project_4.exe: WinRT originate error - 0x80004002 : 'This interface is not supported'.
Exception thrown at 0x00007FF83C644FD9 in My_WinUI_3_project_4.exe: Microsoft C++ exception: winrt::hresult_no_interface at memory location 0x0000005C234FA538.
Exception thrown at 0x00007FF83C644FD9 in My_WinUI_3_project_4.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in My_WinUI_3_project_4.exe.
Call Stack
My_WinUI_3_project_4.exe!winrt::My_WinUI_3_project_4::implementation::App::{ctor}::__l2::<lambda>(const winrt::Windows::Foundation::IInspectable & __formal, const winrt::Microsoft::UI::Xaml::UnhandledExceptionEventArgs & e) Line 31 C++
My_WinUI_3_project_4.exe!winrt::impl::delegate<winrt::Microsoft::UI::Xaml::UnhandledExceptionEventHandler,void <lambda>(const winrt::Windows::Foundation::IInspectable &, const winrt::Microsoft::UI::Xaml::UnhandledExceptionEventArgs &)>::Invoke(void * sender, void * e) Line 4824 C++
[External Code]
My_WinUI_3_project_4.exe!winrt::impl::consume_Microsoft_UI_Xaml_IApplicationStatics<winrt::Microsoft::UI::Xaml::IApplicationStatics>::Start(const winrt::Microsoft::UI::Xaml::ApplicationInitializationCallback & callback) Line 157 C++
My_WinUI_3_project_4.exe!winrt::Microsoft::UI::Xaml::Application::Start::__l2::<lambda>(const winrt::Microsoft::UI::Xaml::IApplicationStatics & f) Line 12146 C++
My_WinUI_3_project_4.exe!winrt::impl::factory_cache_entry<winrt::Microsoft::UI::Xaml::Application,winrt::Microsoft::UI::Xaml::IApplicationStatics>::call<void <lambda>(const winrt::Microsoft::UI::Xaml::IApplicationStatics &) &>(winrt::Microsoft::UI::Xaml::Application::Start::__l2::void <lambda>(const winrt::Microsoft::UI::Xaml::IApplicationStatics &) & callback) Line 6286 C++
My_WinUI_3_project_4.exe!winrt::impl::call_factory<winrt::Microsoft::UI::Xaml::Application,winrt::Microsoft::UI::Xaml::IApplicationStatics,void <lambda>(const winrt::Microsoft::UI::Xaml::IApplicationStatics &)>(winrt::Microsoft::UI::Xaml::Application::Start::__l2::void <lambda>(const winrt::Microsoft::UI::Xaml::IApplicationStatics &) && callback) Line 6309 C++
My_WinUI_3_project_4.exe!winrt::Microsoft::UI::Xaml::Application::Start(const winrt::Microsoft::UI::Xaml::ApplicationInitializationCallback & callback) Line 12147 C++
[External Code]

This:
#include <windows.ui.xaml.media.dxinterop.h>
should be this:
#include <microsoft.ui.xaml.media.dxinterop.h>
when working with WinUI 3.0 Desktop apps and not UWP.

Related

DirectX: can't render a model from CMO

I'm trying to draw a model using DirectX (following this tutorial: https://github.com/Microsoft/DirectXTK/wiki/Rendering-a-model?fbclid=IwAR3A0mw9rzjJHrN3mwgSb9a6oKqNgiDiAnnfkVLIIQVca9Og6cvfvscuVfE).
I've add my model.cmo file with Add existing item and following line to Game::CreateDevice()
m_model = Model::CreateFromCMO(m_d3dDevice.Get(), L"model.cmo", *m_fxFactory);
I can't build and run my project because of exception on aboved line
Unhandled exception at 0x747318A2 in directX_project.exe: Microsoft C++ exception: std::exception at memory location 0x00B3F738. occurred
I will appreciate any tips on how to resolve or debug that issue
You should enable "break on C++ exception" for the debugger as indicated in the instructions here for std::exception so you can see exactly what code triggered the exception.
Note that more recent versions of the DirectX Tool Kit provide more debug output for those kinds of failures which are probably 'file not found' or similar issue.
The DirectX Tool Kit also implements the what method for it's C++ exceptions, so you can use this code to get more detail:
try
{
m_model = Model::CreateFromCMO(m_d3dDevice.Get(), L"model.cmo", *m_fxFactory);
}
catch (std::exception& ex)
{
std::cout << ex.what();
// Do some error handling here or call throw to re-throw it
}

Executing c# code in f# script has unexpected behavior

I have a F# fake script which works with Nuge.Core to extract package files. If I try to do this with c# console app everything works properly. However if I execute exactly the same script in a f# fake script it is not working. There are so many dependencies here and I have no idea where to look for a help: docker.dotnet, fake, f#, nuget.core
To reproduce this you need to download Docker.DotNet.2.124.3.nupkg
For the c# sample you need console application and to install nuget.core nuget package. This is working!
class Program
{
static void Main()
{
var zip = new NuGet.ZipPackage(#"Docker.DotNet.2.124.3.nupkg");
foreach (var file in zip.GetFiles())
{
System.Console.WriteLine(file.Path);
}
}
}
For the f# sample you need these two files side by side:
https://gist.github.com/mynkow/e6f0e550fcacc268dd1e9b743e17d344
ERROR:
==============================================================================
FsiEvaluationException:
Error: System.InvalidOperationException: 'NETStandard.Library' already has a dependency defined for 'Microsoft.NETCore.Platforms'.
at NuGet.Manifest.ValidateDependencySets(IPackageMetadata metadata)
at NuGet.Manifest.Validate(Manifest manifest)
at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider, Boolean validateSchema)
at NuGet.LocalPackage.ReadManifest(Stream manifestStream)
at NuGet.ZipPackage.EnsureManifest(Func`1 manifestStreamFactory)
at NuGet.ZipPackage..ctor(String filePath, Boolean enableCaching)
at <StartupCode$FSI_0005>.$FSI_0005_Test$fsx.main#() in C:\Users\mynkow\Desktop\Reproduce\test.fsx:line 12
Stopped due to error
Output: [Loading C:\Users\mynkow\Desktop\Reproduce\test.fsx]
==============================================================================
Input: C:\Users\mynkow\Desktop\Reproduce\test.fsx
\Arguments:
C:\fsi.exe
Exception: Yaaf.FSharp.Scripting.FsiEvaluationException: Error while compiling or executing fsharp snippet. ---> System.Exception: Operation failed. The error text has been print the error stream. To return the corresponding FSharpErrorInfo use the EvalInteractionNonThrowing, EvalScriptNonThrowing or EvalExpressionNonThrowing
at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.commitResult[a,b](FSharpChoice`2 res)
at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.EvalScript(String filePath)
at Yaaf.FSharp.Scripting.Helper.evalScript#1303.Invoke(String arg00) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1303
at Yaaf.FSharp.Scripting.Helper.save_#1276-2.Invoke(Unit unitVar0) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1277
at Yaaf.FSharp.Scripting.Helper.consoleCapture[a](TextWriter out, TextWriter err, FSharpFunc`2 f) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1221
at Yaaf.FSharp.Scripting.Helper.redirectOut#1247[a](Boolean preventStdOut, OutStreamHelper out, OutStreamHelper err, FSharpFunc`2 f) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1254
at Yaaf.FSharp.Scripting.Helper.save_#1275-1.Invoke(String text) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1276
--- End of inner exception stack trace ---
at Yaaf.FSharp.Scripting.Helper.save_#1275-1.Invoke(String text) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1284
at Yaaf.FSharp.Scripting.Helper.session#1306.Yaaf-FSharp-Scripting-IFsiSession-EvalScriptWithOutput(String ) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1308
at Fake.FSIHelper.runScriptUncached(Boolean useCache, String scriptPath, IEnumerable`1 fsiOptions, Boolean printDetails, CacheInfo cacheInfo, TextWriter out, TextWriter err) in C:\code\FAKE\src\app\FakeLib\FSIHelper.fs:line 471
System.InvalidOperationException: 'NETStandard.Library' already has a dependency defined for 'Microsoft.NETCore.Platforms'.
at NuGet.Manifest.ValidateDependencySets(IPackageMetadata metadata)
at NuGet.Manifest.Validate(Manifest manifest)
at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider, Boolean validateSchema)
at NuGet.LocalPackage.ReadManifest(Stream manifestStream)
at NuGet.ZipPackage.EnsureManifest(Func`1 manifestStreamFactory)
at NuGet.ZipPackage..ctor(String filePath, Boolean enableCaching)
at <StartupCode$FSI_0005>.$FSI_0005_Test$fsx.main#() in C:\Users\mynkow\Desktop\Reproduce\test.fsx:line 12
Stopped due to error
I have tried with the 5 latest versions of all possible dependencies and the results are exactly the same => c# is working, f# is not. Do you have any clue or just anything which you can advise me to try to fix this?
DIRTY SOLUTION:
This is how the Docker.DotNet.2.124.3.nupkg looks like inside
If I remove for example the netstandard1.6 everything works. This means that the problem is in nuget.core, right? But why it is working in c# console app? No idea!
UPDATE: I am able to execute properly the code from F# console application
I've downloaded the packages with paket, and changed the script this way:
#r #"./packages/FAKE/tools/FakeLib.dll"
#r #"./packages/NuGet.Core/lib/net40-Client/NuGet.Core.dll"
open System
open System.Collections.Generic
open System.IO
open Fake
Target "Test" (fun _ ->
printfn "=============================================================================="
global.NuGet.ZipPackage(#"Docker.DotNet.2.124.3.nupkg").GetFiles() |> Seq.iter(fun x -> printfn "%s" x.Path )
)
RunParameterTargetOrDefault "target" "test"
It gives this
Microsoft (R) F# Interactive version 14.0.23413.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
>
--> Referenced 'C:\tmp\visualfsharp.issue.nuget\./packages/FAKE/tools/FakeLib.dll'
--> Referenced 'C:\tmp\visualfsharp.issue.nuget\./packages/NuGet.Core/lib/net40-Client/NuGet.Core.dll'
Building project with version: LocalBuild
Shortened DependencyGraph for Target Test:
<== Test
The resulting target order is:
- Test
Starting Target: Test
==============================================================================
Running build failed.
Error:
System.InvalidOperationException: The schema version of 'Docker.DotNet' is incompatible with version 1.6.30117.9648 of NuGet. Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942.
at NuGet.Manifest.CheckSchemaVersion(XDocument document)
at NuGet.Manifest.ValidateManifestSchema(XDocument document, String schemaNamespace)
at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider)
at NuGet.ZipPackage.EnsureManifest()
at FSI_0002.clo#9.Invoke(Unit _arg1) in C:\tmp\visualfsharp.issue.nuget\test.fsx:line 11
at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in C:\code\FAKE\src\app\FakeLib\TargetHelper.fs:line 493
---------------------------------------------------------------------
Build Time Report
No target was successfully completed
---------------------------------------------------------------------
---------------------------------------------------------------------
val it : unit = ()
>
The version of NuGet.Core is 2.12, and I'm seeing it is referencing Microsoft.Web.Xdt which is not loaded.
Maybe you can achieve what you want by simply using paket and adding Docker.DotNet as a dependency, it will extract it for you.
If you have reproducible error that you described, please make a zip and post an issue to visualfsharp repository.

How can I solve fatal compiler errors when installing GLScene into RAD Studio 2010?

I'm trying to install GLScene into RAD Studio 2010, with the aim of using it from a mostly C++ project. I downloaded the latest snapshot (5991, November 2011) and have been trying to compile and install the two main packages: GLScene_DesignTime and GLScene_RunTime. I haven't even tried some of the other libraries (CUDA, etc), I just want to get the base packages running.
I've encountered a number of problems, one of which I can't solve, and I'm seeking the help of anyone on SO who has successfully installed GLScene, or might know how to solve these Delphi compiler errors.
First problem (solved?)
When compiling, a number of files gave the following error:
[DCC Warning] GLSelection.pas(297): W1025 Unsupported language feature: 'abstract class method'
This is caused by a method declaration something like:
TGLBaseSelectTechnique = class
public
class function IsSupported: Boolean; virtual; abstract;
It seems that a virtual abstract class method is not supported in Delphi 2010, and I have solved it by removing 'abstract' and providing a dummy implementation, e.g. just returning false.
The second problem (not solved) - Delphi compiler fatal errors
I am now encountering two more serious errors. When compiling, the compiler fails like so:
[DCC Fatal Error] Exception EAccessViolation: Access violation at address 05AE8ED9 in module 'dcc140.dll'. Read of address 00000003
[DCC Error] Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
It doesn't say what file caused this, but I think it's caused by Spline.pas. Occasionally and not as often, I get this:
[DCC Fatal Error] Spline.pas(1): F2084 Internal Error: AV062D8ED9-R00000003-0
This indicates Spline.pas, and I think the first error is probably related to the file too, because after getting the first one if I then clean the project, cleaning will fail saying it could not delete Spline.hpp. (I have to close and reopen the IDE.) Spline.hpp just contains the following:
// CodeGear C++Builder
// Copyright (c) 1995, 2009 by Embarcadero Technologies, Inc.
// All rights reserved
// (DO NOT EDIT: machine generated header) 'Spline.pas' rev: 21.00
#ifndef SplineHPP
#define SplineHPP
#pragma delphiheader begin
#pragma option push
#pragma option -w- // All warnings off
#pragma option -Vx // Zero-length empty class member functions
#pragma pack(push,8)
#include <System.hpp> // Pascal unit
#include <Sysinit.hpp> // Pascal unit
and there it stops. It looks to me like it failed when trying to generate the HPP file.
I always get one of these two failures. The second is the only one I can tie to a specific file; the first fails halfway through the project, but I can't see where it got up to when it failed. I am compiling from inside the IDE.
I've looked in Spline.pas, and it seems pretty basic code - I can't see anything unusual at all. You can find it here, and apparently the file hasn't been touched for seven years... so I think it should compile :)
If I change the project settings so it does not generate headers, it compiles fine. (Generating just obj files, and any other of the settings that does not include "headers", all work fine.) But this isn't a good workaround for me - after all, I need to use it from C++ Builder, so my normal setting would be "Generate all C++ Builder files". At a bare minimum, I need HPP and OBJ files.
Has anyone here used GLScene in a recent version of C++ Builder? Have you encountered similar problems? Any idea how to solve this one?
I am using:
RAD Studio 2010 (fully patched and up to date; DDevExtensions and IDEFixPack installed.)
The November 2011 snapshot; I tried the March 2011 snapshot too, and got the same problems. Link to snapshots here.
The Delphi 2010 packages modified only by changing the linker output to generate C++ Builder files; and also the BCB 6 packages. Both give the same errors.
Edit: GLScene now has compatibility with RAD Studio XE3 (including C++ Builder.)
Now there is full compatibility of GLScene with Embarcadero RAD Studio
C++Builder XE3 as in design and runtime mode.
You can download it from http://yadi.sk/d/o1QGI2KA10MK1 (95Mb)
-- from Pal Wassail's post on the Embarcadero forum thread.
{quote:title=David M wrote:}{quote}
Hi,
I'm trying to install GLScene into RAD Studio...
David
And here is more simple Test for EMB developers of Delphi XE3 header generator -
1.Create a VCL Form Application
2.Add in Unit1.pas interface section
type
TVector3f = array[0..2] of single;
TVector4f = array[0..3] of single;
function VectorAdd(const v : TVector3f; const f : Single) : TVector3f; overload;
function VectorAdd(const v : TVector4f; const f : Single) : TVector4f; overload;
3.Add in implementation section
function VectorAdd(const v : TVector3f; const f : Single) : TVector3f;
begin
Result[0]:=v[0]+f;
Result[1]:=v[1]+f;
Result[2]:=v[2]+f;
end;
function VectorAdd(const v : TVector4f; const f : Single) : TVector4f;
begin
Result[0]:=v[0]+f;
Result[1]:=v[1]+f;
Result[2]:=v[2]+f;
Result[3]:=v[3]+f;
end;
Set Delphi Compiler option “Generate C++ .objs, headers, namespaces, export”
Build the project
Then Delphi XE3 compiler generates wrong header file Unit1.hpp with lines:
extern PACKAGE TVector3f __fastcall VectorAdd
(float const v, const float f)/ overload */;
extern PACKAGE TVector4f __fastcall VectorAdd
(float const v, const float f)/ overload */;
If now you are trying to use this header file Unit1.hpp in my.cbproj you get fatal error:
“E2238 Multiple declarations in …”
Yes, if you change vector array types to records:
TVector3f = record
case boolean of
true : (Coord: array[0..2] of single);
false : (X,Y,Z: single);
end;
then the problem could be solved, because in this case Delphi compiler generates
extern PACKAGE Vectortypes::TVector3f __fastcall VectorAdd
(const Vectortypes::TVector3f &v, const float f)/* overload */;
extern PACKAGE Vectortypes::TVector4f __fastcall VectorAdd
(const Vectortypes::TVector4f &v, const float f)/* overload */;
and you could build your C++Builder VCL application without "Multiple declaration " error. It was done for old GLScene version in 2007, but now you need to rewrite some part of code in new library, starting from VectorGeometry.pas module.
There are second way to fix such automatic header's errors - improvement of Delphi compiler in Generating C/C++ headers, namespaces and packages option. But it's in hands of EMB developers.
Here's how I do it:
Download and extract this ZIP file (directly into the root folder of GLScene, allowing it to overwrite as necessary)
Load up the appropriate RAD Studio version (2007 to XE2) and open the file *GLScene_Group.groupproj* (where = your RAD Studio version)
Build/Install each Package in group order
I have carefully assembled these fixed packages to ensure they all install and function properly from 2007 to XE2. Some packages (at the bottom of each group) require additional dependencies to function (such as the Python package) so be mindful of these.
I have tested and confirmed that these work on RAD Studio 2007 to XE2 only.
Don't forget to add the \Source folder (and all subfolders) to the Search Paths (either for the IDE itself or an individual Project, as you desire) otherwise the projects using GLScene components will fail to compile complaining of missing units.
Enjoy!
Not for RAD Studio 2009 but for old GLScene installation in BCB6 she was running well. But current version after installation in RAD Studio XE/XE2/XE3 does not work at all. It seems that the main problem is hidden in overload mechanism of procedures in Vectorgeometry.pas, so Delphi compiler (with using an option for Output of all C++ files and packages) creates coincident strings in Vectorgeometry.hpp and others. Thus you have visual components in C++Builder panel, but your application fails with errors during building. It must be repaired in .pas files by GLScene developers.
When you trying to build an application with GLScene under C++Builder XE3 you will get over 50 BCC32 errors in glcrossplatform.hpp, vectorgeometry.hpp and so on. There is a way to repair the library on your own discretion. Make a new copy of GLScene directory. In GLCrossPlatform.pas rename the procedure RGB to GLRGB (it's work!). Then in VectorGeometry.pas and in many others files of source codes change all overload procedures with slightly different parameter names, so you should't encounter coincident procedures in .hpp files after Delphi option output C++ (last option that includes packages). Then rebuild all GLScene packages. At the end of the process I hope it should work for C++Builder XE3.
I have exact he same errors.
#The second problem
Go to "spline.pas" and change
TCubicSplineMatrix = array of array[0..3] of Single;
to
TCubicSplineMatrixEx = array[0..3] of Single;
TCubicSplineMatrix = array of TCubicSplineMatrixEx;
Now "Rad Studio 2009" can compile and install GLScene for C++Builder. I can start a new C++Builder VCL Application and select GLScene components from the toolbox and drop in my VCL form.
I think, this is the solution for your basic problem, but unfortunately I can not compile my VCL project successful. I get over 50 BCC32 errors in glcrossplatform.hpp and vectorgeometry.hpp. If anyone can help here, that would be great.
#Your First problem
I get this warnings too, but I have nothing changed for it. Just ignore it?!

Msado60_Backcompat crashes in CCommand::CreateParameter

I am developing an ADO application (32 bit) on Windows 7 64 bit SP1 (all updates installed): The app must run on Win XP. According to http://support.microsoft.com/kb/2517589/en-us I am using msado60_backcompat. That worked well until lately, but now it crashes.
My code (snippets):
_CommandPtr cmd(__uuidof(Command));
cmd->ActiveConnection = dbconn;
cmd->CommandText = _T("SELECT [si] FROM [TTable] WHERE [TTable].[ti1]=?");
cmd->Parameters->Append(cmd->CreateParameter(L"#ti1", adTinyInt, adParamInput, 1, 7));
CreateParameter is implemented in msado60_backcompat:
inline _ParameterPtr Command15::CreateParameter ( _bstr_t Name, enum DataTypeEnum Type, enum ParameterDirectionEnum Direction, ADO_LONGPTR Size, const _variant_t & Value )
{
struct _Parameter * _result = 0;
HRESULT _hr = raw_CreateParameter(Name, Type, Direction, Size, Value, &_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _ParameterPtr(_result, false);
}
raw_CreateParameter() calls into msado15.dll into CCommand::CreateParameter. There a crash occurs at offset 0x34f (offset inside the function):
First-chance exception at 0x655ed5a6 (msado15.dll) in adosqlbugcheck.exe: 0xC0000005: Access violation writing location 0xcccccccc.
Unhandled exception at 0x655ed5a6 (msado15.dll) in adosqlbugcheck.exe: 0xC0000005: Access violation writing location 0xcccccccc.
Msado60_Backcompat.tlb: 73728 bytes, 29.4.2011
msado15.dll: 6.1.7601.17514, 1019904 bytes, 21.11.2010
The error does not occur if I use msado15.dll.
Can someone reproduce the error? Is there a solution?
The issue is solved. I was #import-ing the msado60_backcompat.tlb from "C:\Program Files\Common Files". If I import the version from "C:\Program Files (x86)\Common Files" it works. The compiler generates tlh files from both tlb files with exactly the same UUIDs and everything else, they only differ in that the one contains
typedef __int64 ADO_LONGPTR;
typedef ADO_LONGPTR PositionEnum_Param;
While the other contains
typedef long ADO_LONGPTR;
typedef enum PositionEnum PositionEnum_Param;
From my understanding of COM interfaces this should not happen. But since MS commits they really made a mistake it seems to just be the way it is.
Just for information, MS has a new solution coming up: http://blogs.msdn.com/b/psssql/archive/2011/10/03/yes-we-made-a-mistake-and-are-finally-going-to-fix-it.aspx.

Runtime exception(s) when running an F# benchmark on Mono

I am trying to compare the performance of a specific F# benchmark running on .NET and Mono 2.10.2 (Windows 7, 64-bit). I took the Spectral-Norm benchmark from the Benchmarks Game followed the traditional SO advice of using System.Diagnostics.StopWatch for benchmarking C# and added the lines 4, 89-90, and 93-95 at this link. I compiled this code in Visual Studio 2010 (For runtime 4.0, not client profile, any CPU, with optimize code and tail calls turned on). The compiled code runs just fine on .NET (including inside VS), but when I run the .exe on Mono with "mono shootout_spectralnorm.exe" I get the following error (repeated in the fssnip.net link):
Unhandled Exception: System.TypeInitializationException: An exception was thrown
by the type initializer for System.Diagnostics.Stopwatch ---> System.InvalidPro
gramException: Invalid IL code in System.Diagnostics.Stopwatch:.cctor (): method
body is empty.
--- End of inner exception stack trace ---
at Program.main (System.String[] args) [0x00000] in <filename unknown>:0
The strange thing is, when I remove the lines I had added (lines 4, 89-90, and 93-95, which relate to the timing part of the benchmark), the error goes away on Mono, and it acts just like it does on MS .NET. This is just baffling me. I set all of the referenced assemblies in VS to be copied locally, so they should be visible to Mono, but there could be some precedence issue with different assemblies in the GAC that have the same name as the ones in the local folder. Has anyone encountered this issue or a similar one, especially on Windows Mono? If so, or if you think you know how this problem could be fixed, I hope you can help me resolve it.
Reference Assemblies do not (often) have code - they are API signatures only (enough info for the compiler to reference them at design-time/compile-time). You need to copy the runtime assemblies, not the reference assemblies, in order to run it. (You'll often find the runtime assemblies in the GAC.)
Here are measurements for FSharp-2.0.0.0 spectral-norm #2 (Intel Q6600 quad-core, MS Vista 32 bit)
fsc CPU s Elapsed s
500 0.281 0.337
3000 4.883 1.453
5500 15.85 4.212
2.10.2 CPU s Elapsed s
500 0.343 2.222
3000 4.836 3.361
5500 15.912 6.153
C:/Mono-2.10.2/bin/mono.exe C:/FSharp-2.0.0.0/bin/fsc.exe --platform:x86
--optimize+ --out:spectralnorm.exe spectralnorm.fsharpmono-2.fs
C:/Mono-2.10.2/bin/mono.exe --gc=sgen spectralnorm.exe 5500
Now the benchmarks game spectral-norm on MS Vista demo, includes F# on Mono.

Resources