问题:
这里的问题是,当我从.exe file
运行我的项目C:\Program Files (x86)\Atoz\My Product Name
作为管理权时,那时它工作正常,没有错误。但是当我在没有管理权限或管理员权限的情况下从.exe file
运行我的项目desktop or start menu
时,我的错误如下所示。
错误:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Authentication.IsValidUser(String Login_Id, String Pwd) in c:\Users\Administrator\Desktop\CarServiceNew\CarServiceNew\Authentication.cs:line 29
at CarServiceNew.Login.btnLogin_Click(Object sender, EventArgs e) in c:\Users\Administrator\Desktop\CarServiceNew\CarServiceNew\Login.cs:line 25
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.PerformClick()
at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
我对此一无所知。所以,如果有人对这个问题有任何建议或解决方案,那么这将是可以预料的。提前谢谢。
注意
Here i have tried to give support for framework 4 on windows 7 os
此项目已在框架4.5
答案 0 :(得分:0)
我想你已经设置了执行级别。打开你的app.manifest并进行编辑。
重要的剪辑应该是这样的:
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" />
// and so on... //
如果启用了UAC,它应该在app-start上告诉您此工具需要admin-privilegesgs。
修改强>
哦......我想我错过了你的问题。即使以管理员权限???