c# - 无法加载程序集 'Xamarin.Android.Support.v4'

标签 c# android visual-studio xamarin visual-studio-2015

我在 visual studio 2015 中调试我的代码时遇到此错误:

Severity Code Description Project File Line Error Unexpected error - Please file a bug report at http://bugzilla.xamarin.com. Reason: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.v4, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile? DTR_ACMS

我尝试重新安装 Android 支持库 v4。

我的代码:

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Support.V4.App;
using TaskStackBuilder = Android.Support.V4.App.TaskStackBuilder;

namespace DTR_ACMS
{
    [Activity(Label = "DTR_ACMS", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        int count = 1;
        private static readonly int ButtonClickNotificationId = 1000;
        private void ButtonOnClick(object sender, EventArgs eventArgs)
        {
            // Set up an intent so that tapping the notifications returns to this app:
            Intent intent = new Intent(this, typeof(MainActivity));

            // Create a PendingIntent; we're only using one PendingIntent (ID = 0):
            const int pendingIntentId = 0;
            PendingIntent pendingIntent =
                PendingIntent.GetActivity(this, pendingIntentId, intent, PendingIntentFlags.OneShot);

            // Build the notification:
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .SetAutoCancel(true)                    // Dismiss from the notif. area when clicked
                .SetContentTitle("Button Clicked")      // Set its title
                .SetNumber(count)                       // Display the count in the Content Info
                .SetSmallIcon(Resource.Drawable.ic_stat_button_click)  // Display this icon
                .SetContentText(String.Format(
                    "The button has been clicked {0} times.", count)); // The message to display.

            // Finally, publish the notification:
            NotificationManager notificationManager =
                (NotificationManager)GetSystemService(Context.NotificationService);
            notificationManager.Notify(ButtonClickNotificationId, builder.Build());

            // Increment the button press count:
            count++;
        }

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.button1);

            button.Click += ButtonOnClick;
        }
    }
}

最佳答案

您好,我也遇到了类似的问题,如果打开了单个文件,Visual Studio 会给出这样的错误。通过关闭该文件并重新启动 Visual Studio,它解决了我的问题。

https://forums.xamarin.com/discussion/67182/monodroid-error-xa0000-with-unexpected-error-with-reason-system-io-filenotfoundexception

关于c# - 无法加载程序集 'Xamarin.Android.Support.v4',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34617509/

相关文章:

java - Android 自定义通知 RemoView 不使用样式

c++ - 与应用程序的链接错误

visual-studio - 让 Visual Studio 使用 VS 代码快捷键/键绑定(bind)

c# - 搜索和替换文件 .net 2.0 中的文本。我错过了什么?

c# - 不明白<>0是什么意思

c# - 创建弹出气球,如 Windows Messenger 或 AVG

c++ - 将 Visual C++ 项目迁移到 Visual Studio 2013 - DirectShow 基类错误 C2169

c# - 在 using 语句中返回后的位图 ArgumentException

android - 我的应用程序中的谷歌地图不可见

android - 如何在android应用程序中以在线和离线模式加载或检索网页?