Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在发布模式下,不使用.NET本机编译时出现编译错误_C#_.net_Json_Xamarin - Fatal编程技术网

C# 在发布模式下,不使用.NET本机编译时出现编译错误

C# 在发布模式下,不使用.NET本机编译时出现编译错误,c#,.net,json,xamarin,C#,.net,Json,Xamarin,我使用Xamarin.Forms。我使用嵌入的data.json文件作为资源。在调试工作中,但在使用.NET本机编译的版本中,它会因一些错误而崩溃 有人建议我使用此文件并更改RD.XML文件。我应该在里面放些什么来消除我的错误?我的错误 "System.IO.FileNotFoundException" in System.Private.Reflection.Core.dll "System.IO.FileNotFoundException" in System.Private.Reflect

我使用Xamarin.Forms。我使用嵌入的data.json文件作为资源。在调试工作中,但在使用.NET本机编译的版本中,它会因一些错误而崩溃

有人建议我使用此文件并更改RD.XML文件。我应该在里面放些什么来消除我的错误?我的错误

"System.IO.FileNotFoundException" in System.Private.Reflection.Core.dll
"System.IO.FileNotFoundException" in System.Private.Reflection.Core.dll
"System.AggregateException" in System.Private.Threading.dll
"Microsoft.CSharp.RuntimeBinder.RuntimeBinderException" in Microsoft.CSharp.dll
"System.Reflection.MissingMetadataException" in System.Private.CoreLib.dll
"System.Reflection.TargetInvocationException" in System.Private.CoreLib.dll
"System.Reflection.MissingMetadataException" in System.Linq.Expressions.dll
"System.Reflection.MissingMetadataException" in Newtonsoft.Json.dll
"System.Reflection.MissingMetadataException" in Newtonsoft.Json.dll
"System.Reflection.MissingMetadataException"  Newtonsoft.Json.dll
"System.Reflection.MissingMetadataException" in project.UWP.McgInterop.dll
"System.Reflection.MissingMetadataException"  project.UWP.McgInterop.dll
我的代码

        var assembly = typeof(MyClass).GetTypeInfo().Assembly; 

        Stream stream = assembly.GetManifestResourceStream("project.data.json");

        string text = "";
        using (var reader = new System.IO.StreamReader(stream))
        {
            text = reader.ReadToEnd();
        }
        Levels = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Level>>(text, new MyConverter());
var assembly=typeof(MyClass).GetTypeInfo().assembly;
Stream=assembly.GetManifestResourceStream(“project.data.json”);
字符串文本=”;
使用(var reader=new System.IO.StreamReader(stream))
{
text=reader.ReadToEnd();
}
Levels=Newtonsoft.Json.JsonConvert.DeserializeObject(文本,new MyConverter());

如果您将文件作为内容类型文件嵌入到项目中,您可以使用普通文件I/O读取它,并避免使用Reflection。请给出一个示例或链接,以了解更多信息?我没有听说这件事。在xamarin.forms pcl中,据我所知,您不能使用system.ioin表单,您需要使用DI并从平台项目中执行实际的文件I/O。您是否找到了解决方法?如果您将文件作为内容类型文件嵌入项目中,您可以使用普通文件I/O读取该文件,并避免使用Reflection,请给出一个示例这是一个链接还是一个链接?我没有听说这件事。据我所知,在xamarin.forms pcl中,您不能使用system.ioin表单,您需要使用DI并从平台项目执行实际的文件I/O。您找到了解决方法吗?