Unable to build and run Unity application on HoloLens 2 - c#

I'm trying to build my first HoloLens app using Unity. I imported the MRTK and its features. I also connected the HoloLens through USB. As soon as I press "Build and Run" it provides 3 errors. My build settings for Universal Windows Platform are the following:
Target Device: HoloLens,
Architect: ARM (I also tried ARM64),
Build Type: D3D Project,
Target SDK Version: Latest Installed,
Minimum Platform Version: (all the versions give the same error),
Visual Studio Version: Latest Installed,
Build and Run on: USB Device,
Build Configuration: Release.
Regardless of the build settings, the following errors appear as soon as I press the "Build and Run":
BuildFailedException: Deployment failed.
Output:[22:13:39.766] Windows Phone Player Runner started.
[22:13:39.772] Connecting to device.
[22:13:39.788] An error occurred while running: Could not load file or assembly 'Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.SmartDevice.Connectivity.DatastoreManager..ctor(DatastoreConfiguration configuration)
at Microsoft.SmartDevice.Connectivity.DatastoreManager.Get(Int32 localeId)
at Microsoft.SmartDevice.Connectivity.Wrapper.ConnectivityWrapper12.GetCurrentPlatform(Int32 localeId)
at WindowsPhonePlayerRunner.Program.GetDevice()
at WindowsPhonePlayerRunner.Program.Run(String appxPath, RunnerFlags runnerFlags, IEnumerable`1 copyFilesTo)
at WindowsPhonePlayerRunner.Program.Main(String[] args)
[22:13:39.788] Exiting Windows Phone Player Runner.
ApplicationLauncherImpl.RunOnPhone (System.String commandLine)
ApplicationLauncherImpl.Run (Utility+VisualStudio vs)
ApplicationLauncher.BuildAndRunProject (UnityEditor.Modules.BuildLaunchPlayerArgs args, UnityEditor.WSABuildAndRunDeployTarget deployTarget, System.String platform, Utility+VisualStudio vs)
UnityEditor.PostprocessBuildPlayer.Launch (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget buildTarget, System.String path, System.String productName, UnityEditor.BuildOptions options, UnityEditor.Build.Reporting.BuildReport buildReport) (at <55729f52d042492e9efc384182ae2feb>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Build completed with a result of 'Failed' in 177 seconds (176835 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in <55729f52d042492e9efc384182ae2feb>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <55729f52d042492e9efc384182ae2feb>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

From the build log, the "Windows Phone Player Runner" related output should be caused by two possible reasons:
Incorrect Unity version.
Build and Run on: USB Device setting
For Unity version, we recommend using the Unity 2020 LTS version for HoloLens 2 development: https://unity3d.com/unity/qa/lts-releases?version=2020.3
For Build and Run on setting, it the issue is caused by Build and Run on: USB Device setting, this is a known issue and won't fix by Unity. The best practice is, please switch to Local Machine and generate the Visual Studio Project. With the help of Visual Studio, you can deploy to your HoloLens 2 via wireless network or USB cable. See:
Build and deploy the application section in this tutorial
Using Visual Studio to deploy and debug

Related

Publishing WPF Application with EmguCV and Clickonce

I've been trying to publish a WPF application I've been working on to a specific folder using Microsoft Clickonce. In my application I use the OpenCV wrapper EmguCV. However, when I publish the application and download and install it on a new machine, it gets thrown the following error.
Application: Photo.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.DllNotFoundException
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback, IntPtr, IntPtr)
at Emgu.CV.CvInvoke..cctor()
Exception Info: System.TypeInitializationException
at Emgu.CV.CvInvoke.cvCreateImageHeader(System.Drawing.Size, Emgu.CV.CvEnum.IplDepth, Int32)
at Emgu.CV.Image`2[[Emgu.CV.Structure.Gray, Emgu.CV, Version=4.6.0.5131, Culture=neutral, PublicKeyToken=7281126722ab4438],[System.Byte, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].AllocateData(Int32, Int32, Int32)
Whats really confusing me though is if I download my bin folder to that same machine and run the application, it works completely fine. Because of this I know the machine is not missing any runtimes, so it would have to be with Clickonce itself. I've verified that I'm targeting x64, and have also checked that all of the EmguCV dll's are being included in the Application Files section of Clickonce. I've also checked EmguCV's documentation about the issue and I've also verified that I have the correct Nuget package with the Emgu.CV.runtime.windows package.

Xamarin Forms: System.InvalidProgramException: Invalid IL code in Android.Runtime.AndroidTypeManager:RegisterNativeMembers

I'm getting the following exception while building my Xamarin Forms app in release mode:
[GraphicsEnvironment] Neither updatable production driver nor prerelease driver is supported.
[NetworkSecurityConfig] No Network Security Config specified, using platform default
[NetworkSecurityConfig] No Network Security Config specified, using platform default
[MultiDex] VM with version 2.1.0 has multidex support
[MultiDex] Installing application
[MultiDex] VM has multidex support, MultiDex support library is disabled.
[monodroid-gc] GREF GC Threshold: 46080
[CompatibilityChangeReporter] Compat change id reported: 183155436; UID 10158; state: ENABLED
[FirebaseApp] Device unlocked: initializing all Firebase APIs for app [DEFAULT]
[FirebaseInitProvider] FirebaseApp initialization successful
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidProgramException: Invalid IL code in Android.Runtime.AndroidTypeManager:RegisterNativeMembers (Java.Interop.JniType,System.Type,System.ReadOnlySpan`1<char>): IL_0240: stloc.s 19
[mono-rt]
[mono-rt]
[mono-rt] at Android.Runtime.JNIEnv.RegisterJniNatives (System.IntPtr typeName_ptr, System.Int32 typeName_len, System.IntPtr jniClass, System.IntPtr methods_ptr, System.Int32 methods_len) [0x00088] in <7685f94735ec4635bcf7c23732e3db0f>:0
Application while deploying in release mode stuck on splash screen.
XF version: 5.0.0.2545
Visual studio MAC 17.4.1
Referred this thread, but didn't help.

Running mpi with C# programs on OS X

I tried running an mpi program written in C# on OSX, however, I keep getting the permission denied error.
The steps I took to install mpi:
installed homebrew
using homebrew installed mpich
installed mono (so I can get a .exe file)
created a project in Rider, specified target frameworks to be net50 (latest .net core) and net48 (assume provided by mono)
installed mpi.net nuget package
went into the Debug directory of net48 containing ConsoleApp1.exe
ran the command mpirun -np 4 ./ConsoleApp1.exe with and without sudo
However, I get the following error:
[proxy:0:0#Marins-MacBook-Pro.local] HYDU_create_process (utils/launch/launch.c:74): execvp error on file ./ConsoleApp1.exe (Permission denied)
The error is repeated once for each process.
Using finder I selected the exe file and parent folder in question and gave everyone permissions to read and write (read permissions are granted by default). However, the problem still persists.
What can I try to solve this issue?
EDIT:
I also tried with the following command:
mpiexec -n 4 mono ConsoleApp1.exe
However, I get the error:
Unhandled Exception:
System.DllNotFoundException: msmpi.dll assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) MPI.Unsafe.MPI_Finalized(int&)
at MPI.Environment.get_Finalized () [0x00000] in <fa7716c2d3a447518b7b229d8fa8506f>:0
at MPI.Environment..ctor (System.String[]& args, MPI.Threading threading) [0x00006] in <fa7716c2d3a447518b7b229d8fa8506f>:0
at MPI.Environment..ctor (System.String[]& args) [0x00000] in <fa7716c2d3a447518b7b229d8fa8506f>:0
at ConsoleApp1.Program.Main (System.String[] args) [0x00001] in <4afb3f1ea5bc4367a9a7afd6da6576a3>:0
I'm not sure whether this is the correct way to use mpi on OS X.

Emgu Could not found cvextern in IIS server

I'm having some issues running the Emgu on my server. It runs fine locally, but when I try to use it on the server with IIS, it doesnt work.
Here is the error:
System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)\r\n at Emgu.CV.CvInvoke..cctor()
--- End of inner exception stack trace ---
at Emgu.CV.CvInvoke.cvCreateImageHeader(Size size, IplDepth depth, Int32 channels)
at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
at VerifyID.Managers.ImageTreatmentsManager.ExtractDocumentFromImage(Bitmap bitmap)
at VerifyID.VerifyWorker.ExecuteOCR(BigIdRequest request, BigIdEvent bigIdEvent)
I have the following dlls inside the x86 and x64:
concrt140.dll*
liblept172.dll*
msvcp140.dll*
vcruntime140.dll*
cvextern.dll*
libtesseract304.dll*
opencv_ffmpeg320.dll*
IIS version: 10.0
After copying the x64 dlls directly to the bin directory of the build the error changed to:
System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
at Emgu.CV.CvInvoke..cctor()
--- End of inner exception stack trace ---
at Emgu.CV.CvInvoke.cvCreateImageHeader(Size size, IplDepth depth, Int32 channels)
at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
at VerifyID.Managers.ImageTreatmentsManager.ExtractDocumentFromImage(Bitmap bitmap)
at VerifyID.VerifyWorker.ExecuteOCR(BigIdRequest request, BigIdEvent bigIdEvent)
Could someone help ?
I had this same problem, the application works perfectly on the local server (IIS Express used by the Visual Studio) but not on the remote Windows server, the solution that worked for me was:
(Please test your application between each step, maybe you don't need to do them all)
In Visual Studio, open your application project properties and set the "Platform" to "Any CPU". Then publish your application to the remote server.
Move all .dll files inside the x86 folder to the bin folder, pay special attention to the cvextern.dll, it must be inside the bin folder side by side with your application dll.
Install Visual C++ Redistributable for Visual Studio on the remote server (just google it and you will find the download link. Please choose the download version according to your VS version, 2013, 2015, 2017, 2020, 2050...). Use the x86 installation even if you sever OS is x64.
Activate your app_pool for the application for running 32 bit. https://help.webcontrolcenter.com/kb/a1114/how-to-enable-32-bit-application-pool-iis-7-dedicatedvps.aspx
Go to the application \bin folder, grant the file security for the folder "x86" (which contains all the dll for emgu) as described in the following link "http://www.iis.net/learn/manage/configuring-security/application-pool-identities if your apppool being in used in defaulapppool, then you should add user "IIS AppPool\DefaultAppPool"
I really don't know why the x64 versions of those dlls are not working on the server for me. I still investigating it and as soon I find out why I will update this post.
Another solution (that is not elegant at all, but works) is to install the Visual Studio at the server, doing the same installation process that you have done for your development environment. By doing this you will have all dependencies and dlls needed (including the Visual C++) installed on the server.
Hope it helps!

How to create a .app mono bundle for Mac OS

I am trying to create a .app bundle of my mono program to run on Mac OS X, but despite having read virtually all articles and documentation on macpack and bundling mono, none of the methods work.
Using macpack the binaries are bundled successfully in a .app package:
macpack -m:x11 -o:. -r:sqlite3.dll -r:Nini.dll -r:extraIcons.ini -r:APP_DATABASE.db3 -r:APP_Values.db3 -r:./Documents/manual.pdf -r:GemBox.Spreadsheet.dll -r:Mono.Data.SqliteClient.dll -a:APP.exe -n:APP
. When I try to start the program from the package this happens:
FFMACM-2:MacOS dev$ open -a APP
LSOpenURLsWithRole() failed for the application /Users/dev/Workspace/Software/APP.app with error -10810.
I tried using this method but the script fails with the following error:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Nini, Version=1.1.0.0, Culture=neutral, PublicKeyToken=691faec150a7fa7b' or one of its dependencies.
File name: 'Nini, Version=1.1.0.0, Culture=neutral, PublicKeyToken=691faec150a7fa7b'
at APP.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0
logout
I am fresh out of ideas. The Nini.dll is where it should be. I am using GTK# for the GUI.
Creating a package for MacOS X is now done using MonoMacPackager. You can find details here http://www.mono-project.com/MonoMacPackager.
However, the issue that you're seeing here is that you're missing your dll (The Nini assembly) from your package. It needs to be in your application path (after it has been bundled) to load properly.

Categories

Resources