C# 在Xamarin表单中创建Firestore客户端崩溃[无法使用令牌0100003b解析类型]
几天来我遇到了一个问题,我正在尝试以xamarin的形式访问firestore。为此,我使用了环境变量C# 在Xamarin表单中创建Firestore客户端崩溃[无法使用令牌0100003b解析类型],c#,firebase,xamarin,google-cloud-firestore,C#,Firebase,Xamarin,Google Cloud Firestore,几天来我遇到了一个问题,我正在尝试以xamarin的形式访问firestore。为此,我使用了环境变量GOOGLE\u APPLICATION\u CREDENTIALS,如下面的代码所示。环境变量stting成功了,正如您所看到的,我做了一些测试,这部分的一切都正常。但是当我调用方法FirestoreClient.Create()时,出现了以下异常: System.TypeLoadException:无法解析带有标记0100003b的类型(来自typeref,类/程序集System.Runti
GOOGLE\u APPLICATION\u CREDENTIALS
,如下面的代码所示。环境变量stting成功了,正如您所看到的,我做了一些测试,这部分的一切都正常。但是当我调用方法FirestoreClient.Create()
时,出现了以下异常:
System.TypeLoadException:无法解析带有标记0100003b的类型(来自typeref,类/程序集System.Runtime.Loader.AssemblyLoadContext,System.Runtime.Loader,版本=4.0.0.0,区域性=中性,PublicKeyToken=b03f5f7f11d50a3a)
我在版本1.0.0-beta02上使用Google.Cloud.Firestore和Google.Cloud.Firestore.V1Beta1
代码如下:
public void InitializeFirestore()
{
var assembly = Assembly.GetExecutingAssembly();
Stream steam = assembly.GetManifestResourceStream("AIGallery.AppMobile.CarouselReservation.FirestoreDir.Book-A-Room-Bot-13b38d0674e5.json");
string text = "";
//I create the json files to get the path, because can't get the path from an embedded ressource
string json = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "creditential.json");
//Here I just copy past the json file from google inside creditential.json
using (var reader = new StreamReader(steam))
{
text = reader.ReadToEnd();
}
using (var w = new StreamWriter(json))
{
w.WriteLine(text);
w.Flush();
}
//Here was just to be sure everything was wirtten inside json, it works
text = "";
using (var reader = new System.IO.StreamReader(json))
{
text = reader.ReadToEnd();
}
//Set the variable
System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", json);
//See the content, worked well
var t = Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS");
//Here on Create, it crash
client = FirestoreClient.Create();
几天来我一直在想到底出了什么问题,但我还是没弄明白。提前谢谢我想这和你说的是同一个问题,谢谢!所以目前没有解决方案!