小编rum*_*fx0的帖子

WiX安装程序应始终以管理员身份运行

我为.NET WPF应用程序开发了一个带有WiX的自定义安装程序.如果我右键单击并以管理员身份运行,它可以正常工作,但是当没有运行时,由于权限不足,某些组件无法安装.

这些组件包括SQL Server Express 2008 R2,FoxIt Reader,ActiveX组件和其他一些组件.它还要求在新安装的数据库上运行一些SQL脚本 - 无论如何,它们都需要管理员权限.


我尝试将InstallScope ="perMachine"和InstallPrivileges ="elevated"属性添加到Package节点,但这似乎没有什么区别.

我确定这是愚蠢的,但我在参考或在线找不到任何东西.

.net wpf installer wix

15
推荐指数
2
解决办法
2万
查看次数

如何在使用ASP.NET标识确认帐户后执行自动登录

我目前正在开发一个MVC5 Web应用程序,使用ASP.NET Identity 2进行帐户控制,我遇到的具体问题是在电子邮件确认自动登录用户.

所以流程如下:

  1. 用户单击"注册"链接
  2. 输入电子邮件(用户名)/密码,点击注册
  3. 电子邮件将通过"please confirmaccount"URL发送到指定地址
  4. 用户单击该链接,确认电子邮件地址并自动登录

控制器上的确认电子邮件操作如下所示:

[AllowAnonymous]
public async Task<ActionResult> ConfirmEmail(string userId, string code)
{
   // If userId or code is empty, show an error or redirect
   if (userId == null || code == null)
   {
     return View("Error");
   }

   // Attempt to confirm the email address
   var confirmEmailResult = await UserManager.ConfirmEmailAsync(userId, code);

   // Retrieve the user (ApplicationUser)
   var user = await UserManager.Users.FirstOrDefaultAsync(u => u.Id == userId);
   if (user == null)
   {
     // If …
Run Code Online (Sandbox Code Playgroud)

c# asp.net email asp.net-mvc asp.net-identity

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

如何正确设置Silverlight CurrentUICulture/CurrentCulture?

我正在使用C#开发SL5应用程序,我希望将其国际化.我发现以下内容来设置UI文化:

var culture = new CultureInfo(Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName);
Thread.CurrentThread.CurrentUICulture = culture;
Thread.CurrentThread.CurrentCulture = culture;
Run Code Online (Sandbox Code Playgroud)

像DatePicker这样的一些控件似乎可以解决这个问题.如果我使用'd'格式字符串格式化任何日期时间,我仍然会得到默认格式"M/dd/yyyy".

究竟SL如何解释文化以及如何为整个应用程序正确设置?

谢谢

更新:

找到答案:

首先,在Application_Startup中设置适当的文化:

var culture = new CultureInfo("nl-BE");
Thread.CurrentThread.CurrentUICulture = culture;
Thread.CurrentThread.CurrentCulture = culture;
Run Code Online (Sandbox Code Playgroud)

然而,关键因素是添加以下内容以强制RootVisual的文化/语言:

var root = RootVisual as Page;
if (root != null)
{
    root.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);
}
Run Code Online (Sandbox Code Playgroud)

.net c# silverlight localization cultureinfo

7
推荐指数
1
解决办法
6860
查看次数

使用INotifyPropertyChanged实现的奇怪的NullReferenceException

我正在基类中实现INotifyPropertyChanged,如下所示:

public class NotifyPropertyChangedBase : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void RaisePropertyChanged(string propertyName)
    {
        var propChangedHandler = PropertyChanged;

        if (propChangedHandler != null)
        {
            var args = new PropertyChangedEventArgs(propertyName);
            propChangedHandler(this, args);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我使用它如下:

RaisePropertyChanged("Name");
Run Code Online (Sandbox Code Playgroud)

我得到一个NullReferenceException,而参数,"this"和处理程序是非null.任何人都可以对此有所了解吗?

谢谢.

- >例外的完整堆栈跟踪:http://pastebin.com/bH9FeurJ

更新当我覆盖包含此属性的类的实例时发生异常.简化示例:

public class Person : INotifyPropertyChanged
{
    private string _name;
    public string Name
    {
        get { return _name; }
        set
        {
            _name = value;
            RaisePropertyChanged("Name");
        }
    }

// More properties etc.
}
Run Code Online (Sandbox Code Playgroud)

-snip-

public …
Run Code Online (Sandbox Code Playgroud)

.net c# mvvm inotifypropertychanged nullreferenceexception

6
推荐指数
1
解决办法
1713
查看次数