小编cho*_*dze的帖子

在setter中自我订阅PropertyChanged或添加方法调用?

也许这里已经是这样的问题,但我没有找到它.

我有MVVM应用程序,并且ViewModel我必须对某些属性的更改执行一些其他操作(例如,如果View更改它们).哪种方法更好,为什么?

1st - 添加AdditionalAction对setter的调用

public class ViewModel: INotifyPropertyChanged
{
  private int _MyProperty;

  public int MyProperty
  {
    get { return _MyProperty; }
    set
    {
      if (_MyProperty == value) return;
      _MyProperty = value;
      RaisePropertyChanged(() => MyProperty);

      // --- ADDITIONAL CODE ---
      AdditionalAction();
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

第二 - 自我订阅INotifyPropertyChanged

public class ViewModel: INotifyPropertyChanged
{
  public ViewModel()
  {
    // --- ADDITIONAL CODE ---
    PropertyChanged += OnPropertyChanged;
  }

  private int _MyProperty;

  public int MyProperty
  {
    get { return …
Run Code Online (Sandbox Code Playgroud)

c# wpf mvvm inotifypropertychanged

8
推荐指数
1
解决办法
4824
查看次数

ComVisible .NET程序集和app.config

  • 我有.NET程序集,其中一些类标记为 ComVisible
  • 此程序集已注册 regasm /codebase "assembly_path"
  • 我有app.config名称(实际 - - MyAssemblyName.dll.config)在程序集的文件夹中
  • 我通过我的程序集访问appSettings ConfigurationManager.AppSettings["SettingName"]
  • 我有VBScript文件,通过它创建我的COM对象 CreateObject("...")
  • 创建对象时(来自VBScript),ConfigurationManager.AppSettings["SettingName"]返回null.它看起来像程序集没有看到配置文件.

我应该怎么做才能使它可行?

c# app-config comvisible .net-4.0

5
推荐指数
1
解决办法
3560
查看次数

VBA和"类不支持自动化或不支持预期的接口"

我有ComVisible类的.NET程序集.几天前(我可以通过git找到那个时刻发生的事情) - Excel不再看到这个类了.所以:

我有界面

[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface MyInterface { ... }
Run Code Online (Sandbox Code Playgroud)

和班级

[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[ProgId("MyClass.Id")]
public class MyClass { ... }
Run Code Online (Sandbox Code Playgroud)

Excel通过创建实例

Dim c as MyClass
Set c = New MyClass
Run Code Online (Sandbox Code Playgroud)

之前一切都像魅力一样,但删除了一些方法(从界面和类)后,Excel很疯狂 - 它给我一个错误Class doesn't support Automation or does not support expected interface.哪里可以成问题?

  • 我有时检查过一切.删除某些方法后发生错误
  • 这个类是偏的(可能问题出在这里?)
  • 早些时候一切都工作..

.net c# com excel vba

3
推荐指数
1
解决办法
3174
查看次数

标签 统计

c# ×3

.net ×1

.net-4.0 ×1

app-config ×1

com ×1

comvisible ×1

excel ×1

inotifypropertychanged ×1

mvvm ×1

vba ×1

wpf ×1