System.TypeInitializationException at appCallbacks.SetBridge(_bridge)

Hi

Since il2cpp is getting me a strange error, I tried .net compilation and I get System.TypeInitializationException at a line that says appCallbacks.SetBridge(_bridge)

Call Stack

[External Code]

Space Games Comics.exe!Space_Games_Comics.MainPage.MainPage() Line 44 C#
[External Code]
Space Games Comics.exe!Space_Games_Comics.App.InitializeUnity(string args) Line 120 C#
Space Games Comics.exe!Space_Games_Comics.App.OnLaunched(Windows.ApplicationModel.Activation.LaunchActivatedEventArgs args) Line 93 C#


Code

_bridge = new WinRTBridge.WinRTBridge();
appCallbacks.SetBridge(_bridge);

Any help is greatly appreciated.

Do you get any errors when you build from Unity?

I chose ‘Use Net Core’ for compilation overrides and fixed all the errors, so I donot get any errors when building from unity now.

@Aurimas-Cernius
When I built for x86 inside visual studio, the exception was not thrown.
Is that the intended behavior?

I think there is some bug in Visual Studio where you get exception quite randomly. Rebuilding and running again sometimes solves this.

1 Like

@Aurimas-Cernius
Thank you.
I built again without “unity c# project” or “development build” checked and could run the x64 build.
But I am facing two more problems, and this thread is one of them.

This is the other problem.

Hey, I’m having the same issue, and unchecking the Unity c# projects option didn’t resolve it,it just stopped me getting a breakpoint when the exception occurs, and additionally when Building the project in VS Community I get several warnings about dll not found including Unity.Networking and WinRTLegacy.

Setting the project to Use NetCore didn’t help. I’ve read other forums that reccommend using the same versions of split dlls (ie a dll with the same name in the Plugins folder + Plugins/WSA, with settings to overwrite the base one when copmiling for WSA), aswell as other suggestions that 2 files might have the same name, and/or same namespace and/or called the same but ones a .cs and ones a .js file. I’m not sure how to check for these duplicate names in my project without the error pointing me towards one specifically.

any helps greatly appreciated.

Can you provide the output from Visual Studio build?
Also, do you get any errors when building from Unity?

I get 1 error from Unity

“UnassignedReferenceException: The variable meshFilter of TerrainEditorPreview has not been assigned.
You probably need to assign the meshFilter variable of the TerrainEditorPreview script in the inspector.
TerrainEditorPreview.UpdateTerrain () (at Assets/Scripts/Release/Terrain/TerrainEditorPreview.cs:77)
TerrainEditorPreview.Awake () (at Assets/Scripts/Release/Terrain/TerrainEditorPreview.cs:38)
UnityEditor.HostView:OnGUI()”

When rebuilding the solution it says

“Warning Failed to resolve all project references for ‘MyGameProject’. The package restore result for ‘MyGameProject’ may be incomplete. 0”

I have also attached the output window when running in vs community 2015.

I have the latest version of unity, currently v5.3.1p3, I needed the additional patch 3 to sort an error when running the game to do with shaders.

I ran a blank project fine, so I don’t think there’s an issue with my sdk or anything installed, althought there was literally nothing in my blank project but the standard unity background, I am going to put my plugins over 1 by 1 now to see if one shows an issue.

I tried setting the IL2CPP scripting backend setting which is suggested in other similar Windows Store Unity error threads but it doesn’t build in editor, I’m not totally sure if this is a setting that should be used/tried or not.

Thanks for the quick response, I notice alot of people are having similar troubles so hopefully it can get sorted.

2465191–169643–debug on local machine in vs log.txt (9.38 KB)

Can you make a clean build from Unity then build in VS and provide the contents of Output window (after build, not run).

Sure thing just a sec…

Do you want the output when building the solution, or the individual MyGameProject project? When ticking Build Unity c# projects in the editor build settings dialogue window, it creates 2 additional projects assembly-csharp and assembly-csharp-firstpass.

All of it.

Hey, Here are the logs. I rebiult the solution but had ARM selected insteda of the suggested x86 from unity docs. So I’ll rebuild it in x86 now and post it.

Edit: added x86 rebuild log, thought I tihnk it’s identical.

2465302–169655–rebuild project log.txt (271 KB)
2465302–169656–build solution log.txt (1.33 KB)
2465302–169660–Rebiuld Project in x86.txt (278 KB)

No idea now. Can you try building to an empty directory without C# projects enabled. If it still fails the same way, then report a bug with this project attached, cause I’ll have to debug to figure out what’s going wrong.

Hey, It still occured in the empty directory, I filed a bug report and it’s uploading now.

Thank you so much for your help on this, please let me know if there’s any additional info you need, or if I need to let you know the bug report numbers or webpage etc when it’s finished uploading.

If it happens on an empty project, this points to something being corrupted within Unity installation itself… Could you try reinstalling Unity?

It doesn’t happen on an empty project, I can run that fine in visual studio and it doesn’t get the exception, so I believe it’s something in the project but I have no clue as to what specific file or set of files could be causing it.

When you said to put it into an empty directory, I using Unity to build the App to that new empty directory. Is that what you meant I should try to do, or did I misread that? Sorry if I did.

Can you tell the case number?

Oh I misread you. Sorry about that.