Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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# 从另一个类派生类会导致Com注册错误_C#_Wpf_Class_Inheritance - Fatal编程技术网

C# 从另一个类派生类会导致Com注册错误

C# 从另一个类派生类会导致Com注册错误,c#,wpf,class,inheritance,C#,Wpf,Class,Inheritance,我有一个遵循WPF/MVVM模式的项目。我尝试从PropertyChangedBase派生ViewModel类,以便能够通知视图的数据更改。当我从PropertyChangeBase派生类并编译时,我得到一个错误消息 错误1无法注册程序集D:\Source\ArcOnline\bin\Debug\ArcOnline.dll。无法加载文件或程序集“Major,Version=3.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。系统找不到指定的文件

我有一个遵循WPF/MVVM模式的项目。我尝试从PropertyChangedBase派生ViewModel类,以便能够通知视图的数据更改。当我从PropertyChangeBase派生类并编译时,我得到一个错误消息

错误1无法注册程序集D:\Source\ArcOnline\bin\Debug\ArcOnline.dll。无法加载文件或程序集“Major,Version=3.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。系统找不到指定的文件

下面是我的类的定义

using ArcOnline.WPF;
using System;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace ArcOnline.ViewModels
{
    /// <summary>
    /// The class handles the template for a single 
    /// </summary>
    public class TemplatesViewModel : PropertyChangedBase
    {
        /// <summary>
        /// 
        /// </summary>
        public ArcOnlineViewModel ArcManager { get; set; }

        private string _layerID;
        /// <summary>
        /// Layer ID
        /// </summary>
        public string LayerID
        {
            get { return _layerID; }
            set { _layerID = value; NotifyOfPropertyChange(() => LayerID); }
        }

        private string _title;
        /// <summary>
        /// Title of the layer
        /// </summary>
        public string Title
        {
            get { return _title; }
            set { _title = value; NotifyOfPropertyChange(() => Title); }
        }
using Component.Linq.Expressions;
using System;
using System.Collections;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Runtime.Serialization;
using System.Xml.Serialization;
#endregion

namespace Component.ComponentModel
{
    /// <summary>
    /// A base class from which ViewModels can inherit to improve the quality of
    /// patterns such as INotifyPropertyChanged.
    /// </summary>
    [DataContract]
    [Serializable]
    public class PropertyChangedBase : INotifyPropertyChanged, INotifyDataErrorInfo, IDataErrorInfo
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyChangedBase"/> class.
        /// </summary>
        public PropertyChangedBase()
        {
            ErrorsChanged += Notify_ErrorChanged;
        }

        void Notify_ErrorChanged(object sender, DataErrorsChangedEventArgs e)
        {
            NotifyOfPropertyChange(() => Error);
        }

 ...... More class definition continues

}
。。。。。。。。。。。。。更多属性如上所述 }

下面是我的PropertyChangedBase是如何定义的

using ArcOnline.WPF;
using System;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace ArcOnline.ViewModels
{
    /// <summary>
    /// The class handles the template for a single 
    /// </summary>
    public class TemplatesViewModel : PropertyChangedBase
    {
        /// <summary>
        /// 
        /// </summary>
        public ArcOnlineViewModel ArcManager { get; set; }

        private string _layerID;
        /// <summary>
        /// Layer ID
        /// </summary>
        public string LayerID
        {
            get { return _layerID; }
            set { _layerID = value; NotifyOfPropertyChange(() => LayerID); }
        }

        private string _title;
        /// <summary>
        /// Title of the layer
        /// </summary>
        public string Title
        {
            get { return _title; }
            set { _title = value; NotifyOfPropertyChange(() => Title); }
        }
using Component.Linq.Expressions;
using System;
using System.Collections;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Runtime.Serialization;
using System.Xml.Serialization;
#endregion

namespace Component.ComponentModel
{
    /// <summary>
    /// A base class from which ViewModels can inherit to improve the quality of
    /// patterns such as INotifyPropertyChanged.
    /// </summary>
    [DataContract]
    [Serializable]
    public class PropertyChangedBase : INotifyPropertyChanged, INotifyDataErrorInfo, IDataErrorInfo
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyChangedBase"/> class.
        /// </summary>
        public PropertyChangedBase()
        {
            ErrorsChanged += Notify_ErrorChanged;
        }

        void Notify_ErrorChanged(object sender, DataErrorsChangedEventArgs e)
        {
            NotifyOfPropertyChange(() => Error);
        }

 ...... More class definition continues

}
这个PropertyChangedBase实际上是在另一个项目中定义的,因此它包含了所有头文件。如果我复制这个PropertyChangedBase类的代码,并在我自己的项目中创建一个新类,在该项目中定义了TemplatesViewModel,然后使用它,那么它工作得非常好

我只是想知道在第一种情况下它不起作用的原因是什么??这浪费了我一整天的时间


提前感谢

据我所知,您不能拥有一个同时包含INotifyOfPropertyChanged接口的可序列化类。尝试删除其中一个,然后尝试重建。。。如果它生成,那就是你的问题。头文件?COM注册??你到底在干什么?确保已关闭“为COM互操作注册”选项。