TypeLoadException: Requested Windows Runtime is not registered

So I had been using this Windows SDK for Facebook to make an Unity Plugins and using in my game.

But when I build into Visual project then run it on my Device it show this error , and I have no idea what does it mean , so does anyone know why this error appear .

The full error stack is :

TypeLoadException: Requested Windows Runtime type ‘Facebook.FBSession’ is not registered.
at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
at Facebook.FBSession.get_ActiveSession()
at WPUniversalFB.WPFacebook.Init(String fbAppId, String winAppId)
at SocialFacebookWP.Initialize(Action callback)
at SocialMgr.Initialize(Action callback, SocialType type)
at StartSceneController.OnLoginCommand(DataTable data)
at StartSceneController.OnMessage(DataTable data)
at MessageDistributionLayer.OnMessage.Invoke(DataTable message)
at MessageDistributionLayer.Dispath(DataTable message)
at MessageDistributionLayer.d__2.MoveNext()
at UnityEngine.Internal.$MethodUtility.$Invoke21070(Int64 instance, Int64* args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)

Thanks.

I have added these line in package.appxmanifest

Facebook.winmd

Then it show another error

Exception: Error in the DLL (Exception from HRESULT: 0x800401F9 (CO_E_ERRORINDLL))
Type: System.Runtime.InteropServices.COMException
Module: mscorlib
InnerException:
AdditionalInfo:
at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
at Facebook.FBSession.get_ActiveSession()
at WPUniversalFB.WPFacebook.Init(String fbAppId, String winAppId)
at SocialFacebookWP.Initialize(Action callback)
at SocialMgr.Initialize(Action callback, SocialType type)
at StartSceneController.OnLoginCommand(DataTable data)
at StartSceneController.OnMessage(DataTable data)
at MessageDistributionLayer.OnMessage.Invoke(DataTable message)
at MessageDistributionLayer.Dispath(DataTable message)
at MessageDistributionLayer.d__2.MoveNext()
at UnityEngine.Internal.$MethodUtility.$Invoke21070(Int64 instance, Int64* args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)

Does anyone know about this :frowning:

Thanks.

Are you calling it on UI thread? That is a likely reason.

How did you build the DLL? CO_E_ERRORINDLL usually indicates a build issue.

Hi, @BrokenAngel , Let me know if you solve the problem.

Also looking for a solution. A work-around that seems to work is to reference the whole winfbsdk-project instead of the .winmd file.

I still can’t solve this :frowning:

Hello dear.

I faced this problem in another C# project that I was working on.
My problem was because the build (publish) configuration that I was using were removing all unused assemblies.
I guess that you can try to remove this option and if solve your problem, please let me know.