Several errors and warnings for IronRuby / C# Windows Phone app - windows-phone-7

I'm trying to call IronRuby code from a C# Windows Phone application, but when I try to build the project, I get several errors.
All the tutorials are outdated, so I'm doing my best. I installed the Windows Phone SDK, then installed IronRuby, then created a C# application for Windows Phone (there was no IronRuby template).
Visual Studio didn't know where to find the IronRuby DLLs, so I browsed and added them manually. All the tutorials say to use Silverlight, but there is no longer a Silverlight template for Windows Phone Visual Studio 2012, and the Silverlight DLL generates its own spurious errors.
Code
https://github.com/mcandre/ios7crypt/tree/master/WindowsPhone
Trace
Warning 1 Reference to type 'System.Dynamic.IDynamicMetaObjectProvider' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71\System.Core.dll', but it could not be found c:\Program Files (x86)\IronRuby 1.1\Silverlight\bin\Microsoft.Scripting.dll IOS7Crypt
Warning 2 Reference to type 'System.Dynamic.IDynamicMetaObjectProvider' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71\System.Core.dll', but it could not be found c:\Program Files (x86)\IronRuby 1.1\Silverlight\bin\Microsoft.Scripting.dll IOS7Crypt
Warning 3 Reference to type 'System.Dynamic.IDynamicMetaObjectProvider' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71\System.Core.dll', but it could not be found c:\Program Files (x86)\IronRuby 1.1\Silverlight\bin\Microsoft.Scripting.dll IOS7Crypt
Warning 4 Reference to type 'System.Dynamic.IDynamicMetaObjectProvider' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71\System.Core.dll', but it could not be found c:\Program Files (x86)\IronRuby 1.1\Silverlight\bin\Microsoft.Scripting.dll IOS7Crypt
Warning 5 Reference to type 'System.Dynamic.IDynamicMetaObjectProvider' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71\System.Core.dll', but it could not be found c:\Program Files (x86)\IronRuby 1.1\Silverlight\bin\Microsoft.Scripting.dll IOS7Crypt
Error 6 Predefined type 'Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported C:\Users\andrew\Desktop\src\ios7crypt\WindowsPhone\IOS7Crypt\CSC IOS7Crypt
Error 7 Predefined type 'Microsoft.CSharp.RuntimeBinder.Binder' is not defined or imported C:\Users\andrew\Desktop\src\ios7crypt\WindowsPhone\IOS7Crypt\CSC IOS7Crypt
Error 8 Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference? C:\Users\andrew\Desktop\src\ios7crypt\WindowsPhone\IOS7Crypt\MainPage.xaml.cs 22 25 IOS7Crypt
Error 9 Cannot implicitly convert type 'Microsoft.Scripting.Hosting.ScriptRuntime' to 'Microsoft.Scripting.Hosting.ScriptEngine' C:\Users\andrew\Desktop\src\ios7crypt\WindowsPhone\IOS7Crypt\MainPage.xaml.cs 27 22 IOS7Crypt
Error 10 One or more types required to compile a dynamic expression cannot be found. Are you missing a reference? C:\Users\andrew\Desktop\src\ios7crypt\WindowsPhone\IOS7Crypt\MainPage.xaml.cs 33 27 IOS7Crypt
Error 11 One or more types required to compile a dynamic expression cannot be found. Are you missing a reference? C:\Users\andrew\Desktop\src\ios7crypt\WindowsPhone\IOS7Crypt\MainPage.xaml.cs 39 31 IOS7Crypt
Specs
IronRuby 1.1
Windows Phone Visual Studio 2012
Windows 8 Professional x64
MacBook Pro mid-2009

Related

"The XamarinTelemetry task failed unexpectedly" on second build

With the latest VS preview (VS 17.3 Preview 3), with both Android and iOS, building my application works the first time I build it, but the second time it fails with
The "XamarinTelemetry" task failed unexpectedly.
Looking at the logs I see this:
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: The "XamarinTelemetry" task failed unexpectedly.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: File name: 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: at Microsoft.VisualStudio.Telemetry.TelemetrySessionSettings.GetFaultEventBucketFilterJson(List`1 bucketFilters)
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: at Microsoft.VisualStudio.Telemetry.TelemetrySessionSettings.ToString()
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: at Microsoft.VisualStudio.Telemetry.TelemetrySession.SerializeSettings()
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: at Xamarin.Common.Tasks.Telemetry.GetSession(IBuildEngine4 buildEngine, String vsTelemetrySession) in D:\a\_work\1\s\src\MSBuild\Xamarin.Common.Tasks\Telemetry.cs:line 62
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: at Xamarin.Common.Tasks.XamarinTelemetry.Execute() in D:\a\_work\1\s\src\MSBuild\Xamarin.Common.Tasks\XamarinTelemetry.cs:line 31
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018:
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: WRN: Assembly binding logging is turned OFF.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: Note: There is some performance penalty associated with assembly bind failure logging.
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018: To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Xamarin.Sdk.targets(138,9): error MSB4018:
The only workaround I've found is to clean the entire solution and rebuild, which succeeds, but then fails again the next time I try to build.
Has anyone found a solution to this?
First off, don't shoot the messenger here..
UPDATE: August 16, 2022
According to Visual Studio v17.3.1's Release Notes, this issue has been resolved. However, if not, there's still the following
As per the workaround thread on Visual Studio's dev community thread:
Open, Xamarin.Sdk.targets in Admin Mode (I use, Notepad++)
C:\Program Files\Microsoft Visual Studio\2022\Preview\Msbuild\Xamarin\Xamarin.Sdk.targets
Comment out the <XamarinTelemetry ... />
Save file and rebuild the solution.
Though it does work in the interim, please forward your official feedback on the official VS Developer Community thread in the link below.
https://developercommunity.visualstudio.com/t/Unexpecter-error-of-task-Xamarin-Teleme/10096527
https://developercommunity.visualstudio.com/t/XamarinTelemetry-task-failed-unexpectedl/10100083
There are several config files in the VS installation which reference 13.0.0.0
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
I replaced these with
<bindingRedirect oldVersion="0.0.0.0-13.0.1.0" newVersion="13.0.1.0" />
and was able to build.
It seems that the 13.0.0.0 is not publicly available as nuget package...
In Visual Studio 17.3.0, I right-clicked on the projects and selected "Clean".
Then I tried again to right-click the project and selected "Build" and it worked, the "The XamarinTelemetry task failed unexpectedly" error did not occur.
This is in a solution that contains a .NET Standard 2.0 library that references Xamarin Forms and the project in question is an ASP.NET Core 3.1 API referencing the library.
There are fixed minor-version editions of VS available, for example "2022 LTSC 17.2".
Install it parallel to your current VS or exclusively.
https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-history#evergreen-bootstrappers
Direct downloads:
Enterprise 2022 - 17.2 LTSC
Professional 2022 - 17.2 LTSC
Community is not available
I prefer this over the modification of your 17.3 installation.
It also appears with a different name, so it's easy to distinguish.
start menu
VS installer
I experienced this today and all I did was rebuild the solution, clicked the "save all", closed the application and opened it again but it did not work. I rebuilt the project but it did not work either. So again, I just repeat the process by closing the visual studio, rebuild and run 2 times (also I went to the error file just viewed it) and it works fine. I don't know what differences it made but it works when you repeat the process.
Edit: The error is still repeating. I just use the Factory Reset when the error occurs.
I had the exact same issue with my Xamarin forms solution, after upgrading from 17.2 to 17.3.
Today I installed 17.3.2. A dozen builds later and it seems that the issue has been addressed.

Linking with Apache Portable Runtime on MS Windows

I'm trying to build a Python extension which links to APR. And this time it's on MS Windows... (It works on Linux).
Here's where the build fails, the command, and the output formatted for readability:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe
/nologo
/INCREMENTAL:NO
/LTCG
/DLL
/MANIFEST:EMBED,ID=2
/MANIFESTUAC:NO
/LIBPATH:c:\dev\protopy\lib/apr
/LIBPATH:c:\bin\python\Libs
/LIBPATH:c:\dev\protopy\.venv\libs
/LIBPATH:c:\dev\protopy\.venv\PCbuild\amd64
"/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64"
"/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64"
"/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64"
apr-1.lib
/EXPORT:PyInit_wrapped build\temp.win-amd64-3.6\Release\protopy/lib/descriptors.obj
build\temp.win-amd64-3.6\Release\protopy/lib/binparser.obj
build\temp.win-amd64-3.6\Release\protopy/lib/defparser.obj
build\temp.win-amd64-3.6\Release\protopy/lib/protopy.lex.obj
build\temp.win-amd64-3.6\Release\protopy/lib/protopy.tab.obj
build\temp.win-amd64-3.6\Release\protopy/lib/pyhelpers.obj
build\temp.win-amd64-3.6\Release\protopy/lib/list.obj
build\temp.win-amd64-3.6\Release\protopy/wrapper.obj
/OUT:build\lib.win-amd64-3.6\protopy\wrapped.cp36-win_amd64.pyd
/IMPLIB:build\temp.win-amd64-3.6\Release\protopy/lib\wrapped.cp36-win_amd64.lib
wrapper.obj : warning LNK4197: export 'PyInit_wrapped' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.6\Release\protopy/lib\wrapped.cp36-win_amd64.lib \
and object build\temp.win-amd64-3.6\Release\protopy/lib\wrapped.cp36-win_amd64.exp
descriptors.obj : error LNK2001: unresolved external symbol \
__imp_apr_hash_set
(it actually misses all symbols I've used, not just this one).
I've built the apr-1.lib by running nmake -f Makefile.win in APR's top-level directory before, and this is how I produced libapr-1.lib. Then I renamed to apr-1.lib it and put it in c:\dev\protopy\lib/apr, so the linker is actually able to find it, but it cannot find the required symbols...
Question 1
How can I see what symbols are in the library? (Maybe I compiled something wrong?)
OK, I found dumpbin.exe, but now I see that the symbol in the apr-1.lib is called __imp__apr_hash_set (notice the second double underscore), but the linker looks for __imp_apr_hash_set (single underscore). What gives? They were compiled with the same compiler / linker...
Question 2
Is there anything specific to building Python extensions on MS Windows that makes it work in this way? (I only tried this once in my life, and couldn't get it to work, but for different reasons).
According to APR project document
choose either aprutil or libaprutil (for static or dynamic libraries)
means apr-1.lib-->static and libapr-1.lib -->dynamic and
To target the static .lib versions of the library, the consuming compiliation must define the macros APR_DECLARE_STATIC and APU_DECLARE_STATIC. This prevents the apr and apr-util symbols from being tagged as __declspec(dllimport), eliminating compiliation warnings and speeding up execution.

Clang C2 on Visual studio 15.5 bool_constant<__is_trivially_destructible(_Ty)> error : '_Ty' does not refer to a value

I am trying to re-compile a hello world using Clang_C2 compiler on Visual studio 15.5 (latest).
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\type_traits(899,2): error : expected class name
1> { // determine whether _Ty has a trivial destructor
In file included from ..\hello_boost_exception\hello_boost_exception.cpp:11:
1>In file included from I:\modular-boost\boost/config.hpp:48:
1>In file included from I:\modular-boost\boost/config/stdlib/dinkumware.hpp:98:
1>In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\typeinfo:22:
1>In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\exception:7:
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\type_traits(898,47):
This looks as though I have some missing or incorrect library but I can't see what.
I have try various compiler versions C++14 (-std=c++1y) and library -stdlib=libc++ (should it use dinkumware version of type_traits?) but the error persists.
Suggestions most welcome.
Paul

winnt.h causes issues post-update

EDIT:
I gave up on making the SDK work properly and instead am using MinGW's provided Windows headers. As for the issue with SDL, I just commented out some lines about Windows RT, which in my case is probably fine as I never plan to compile for mobile devices.
I recently went and grabbed the Windows SDK 8.1 to replace 7.1, which I had to do because I went and grabbed SDL 2.0.3 to replace 2.0.1, and SDL now depends on a file "winapifamily.h" which is only in the 8.x SDK and not 7.x, and it wasn't that big a deal... until I went over to a networking project I've been working on. My code is not the problem, it's my environment. Now that the newer SDK is set up, winnt.h is causing massive problems.
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h|940|error: #error Must define a target architecture.|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h|1311|error: 'EXCEPTION_DISPOSITION' does not name a type|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h|1320|error: 'EXCEPTION_ROUTINE' does not name a type|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h||In function 'BYTE ReadUCharAcquire(const volatile BYTE*)':|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h|8287|error: 'ReadAcquire8' was not declared in this scope|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h||In function 'BYTE ReadUCharNoFence(const volatile BYTE*)':|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h|8298|error: 'ReadNoFence8' was not declared in this scope|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h||In function 'void WriteUCharRelease(volatile BYTE*, BYTE)':|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h|8321|error: 'WriteRelease8' was not declared in this scope|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h||In function 'void WriteUCharNoFence(volatile BYTE*, BYTE)':|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h|8334|error: 'WriteNoFence8' was not declared in this scope|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h||In function 'WORD ReadUShortAcquire(const volatile WORD*)':|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h|8359|error: 'ReadAcquire16' was not declared in this scope|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h||In function 'WORD ReadUShortNoFence(const volatile WORD*)':|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h|8370|error: 'ReadNoFence16' was not declared in this scope|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h||In function 'void WriteUShortRelease(volatile WORD*, WORD)':|
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h|8393|error: 'WriteRelease16' was not declared in this scope|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 10 errors, 0 warnings (0 minutes, 39 seconds) ===|
I have been tampering with my environment for about eight hours now and even re-installed MinGW thinking that perhaps it had some outdated headers or libs or something. It is probably something very simple I'm missing, if anyone has any idea what could be causing these issues I would appreciate any help.
Does Microsoft just write unreliable headers? Is the SDK only for Visual Studio compilers, and if so why are there many instances of the letters 'GNU' and 'GCC' in many Windows headers, even winnt.h?
I know this is a bit too late, but for those with still the same problem.
The problem indeed stems from the environment. Particularly, from the include directories pointing to 2 different versions of winnt.h and in your case, probably also winsock2.h given that you say it is a network app you're dealing with.
Background: there are 2 lists of include files in your proyect. One comes from your proyect settings, the second one comes from the global includes defined in the compiler settings, in that order.
Perhaps, in your previous configuration, winnt.h, winsock2.h etc. were taken from the global settings, which pointed to the Mingw provided files, but now, for sure, they are in the include paths of the SDK (that happend to me as well).
Your problem is one of precedence. The "windows" files from the SDK don't work with Mingw, so much that Mingw includes those files, but modified.
What you have to do is, put on top of the list, in your proyect settings' include directories, the same directory that you find in the global settings that point to the Mingw provided files, in such a way that these windows files are taken from the ones included in Mingw and not the SDK.
Hope this helps.

Building with Visual Studio 2010, MFC, and FFmpeg

I'm working on building a Windows MFC application in Visual Studio 2010 using FFmpeg and SDL. However, I can't get the project to build after creating an MFC project from scratch and including the FFmpeg development libraries (avcodec.lib, avdevice.lib, avformat.lib, etc.). I'm using the development build from Zeranoe FFmpeg. I have configured the following in the Project Properties:
Set VC++ Directories -> Include Directories (added the FFmpeg "include" directories)
Set VC++ Directories -> Library Directories (to the FFmpeg "lib" directory)
Set Linker -> Input -> Additional Dependencies (to include avcodec.lib, etc.)
For what it's worth, the build succeeds when I omit FFmpeg's "include\libavutil" include from the VC++ Directories -> Include Directories.
Below are some of the first build errors I'm receiving (I won't post all, since it's long). Any help would be appreciated.
ClCompile:
stdafx.cpp
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atltime.h(371): error C3861: '_mktime64': identifier not found
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atltime.h(386): error C3861: '_localtime64_s': identifier not found
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atltime.h(409): error C3861: '_gmtime64_s': identifier not found
c:\program files\microsoft sdks\windows\v7.0a\include\intsafe.h(144): warning C4005: 'INT8_MIN' : macro redefinition
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxtaskspane.h(279): error C2146: syntax error : missing ';' before identifier 'm_nLastAnimTime'
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxribboncategory.h(282): error C2146: syntax error : missing ';' before identifier 'm_ActiveTime'
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxdockingmanager.h(353): error C2146: syntax error : missing ';' before identifier 'm_clkLastTime'
Build FAILED.
I've referenced both of these articles, which were of help:
Visual Studio and libavcodec
Visual Studio and SDL
I think what you did is this. When you did your first 2 steps
Set VC++ Directories -> Include Directories (added the FFmpeg
"include" directories)
Set VC++ Directories -> Library Directories
(to the FFmpeg "lib" directory)
You have included them at the top of the list before MFC and ATL paths. Please move them to the bottom of the list using the up/down buttons. This should solve the problem
Have a look at Use FFmpeg in Visual Studio - it has a link to small Visual Studio 2010 project that builds against Zeranoe binaries.
Note that you need a inttypes.h file to succeed in building.
Your log shows issues with stdafx.cpp and this means that you have either search paths set wrong, or something is wrong in stdafx.h. Putting FFmpeg directories on top of search list might work out, however it might equally well break building for MFC part. I would rather have them on the bottom of the list, however the code itself should have the correct order of explicit #includes.

Resources