如何通过c#.net windows应用程序解决Windows 8中的权限问题? [英] How to resolve permission issue in windows 8 through c# .net windows application?

查看:160
本文介绍了如何通过c#.net windows应用程序解决Windows 8中的权限问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我开发了一个.net windows应用程序。

当我在Windows 8中运行应用程序时,它就会出现错误。

许可问题。



有关调用

just-in的详细信息,请参阅此消息的结尾-time(JIT)调试而不是这个对话框。



**************例外文字****** ********

System.ArgumentException:拒绝访问路径。

at System.IO.FileSystemInfo.set_Attributes(FileAttributes value)

at Vint3DWinApplication.Form1.Form1_Load(Object sender,EventArgs e)

at System.Windows.Forms.Form.OnLoad(EventArgs e)

at System .Windows.Forms.Form.OnCreateControl()

在System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

在System.Windows.Forms.Control.CreateControl ()

在System.Windows.Forms.Control.WmShowWindow(消息& m)

在System.Wi ndows.Forms.Control.WndProc(消息&安培; m)

在System.Windows.Forms.ScrollableControl.WndProc(消息& m)

在System.Windows.Forms.ContainerControl.WndProc(Message& m)
(消息& m)

在System.Windows.Forms.Form.WndProc(消息& m)
$ b System.Windows.Forms.Control.ControlNativeWindow.OnMessage上的$ b(消息& m)

在System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)





* *************已装载的装配**************

mscorlib

装配版本:4.0 .0.0

Win32版本:4.0.30319.34014内容:FX45W81RTMGDR

CodeBase:file:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/ mscorlib.dll

--------------------------------------- -

Vint3DWinApplication

汇编版本:1.0.0.0

Win32版本:1.0.0.0

CodeBase:file:/// C:/ Program%20Files%20(x86)/ Vint3D / Vint3DSetup /Vint3DWinApplication.exe

-------------------------------------- -

System.Windows.Forms

汇编版本:4.0.0.0

Win32版本:4.0.30319.33440内容:FX45W81RTMREL
CodeBase:file:/// C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

----------------------------------------

System.Drawing

汇编版本:4.0.0.0

Win32版本:4.0.30319.33440内容:FX45W81RTMREL

CodeBase:file:/ //C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

---------- ------------------------------

系统

汇编版本: 4.0.0.0

Win32版本:4.0.30319.3 4003建立者:FX45W81RTMGDR

CodeBase:file:/// C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

----------------------------------------



************** JIT调试**************

启用实时(JIT)调试,此

应用程序或计算机(machine.config)的.config文件必须在系统中设置

jitDebugging值。 windows.forms部分。

应用程序也必须使用调试编译

启用。



例如:



< configuration>

< system.windows.forms jitdebugging =true>





启用JIT调试后,任何未处理的异常

将被发送到计算机上注册的JIT调试器

而不是由此对话框处理。



我的应用程序在win7上成功运行d winxp。

但是它没有在win8中运行。



我们如何开发可比性.net windows应用程序?



请帮帮我。



先谢谢。





Ankit Agarwal

软件工程师

Hello,

I have developed a .net windows application.
When i am running application in windows 8 so it's coming error.
Permission issue.
and
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: Access to the path is denied.
at System.IO.FileSystemInfo.set_Attributes(FileAttributes value)
at Vint3DWinApplication.Form1.Form1_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.34014 built by: FX45W81RTMGDR
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Vint3DWinApplication
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files%20(x86)/Vint3D/Vint3DSetup/Vint3DWinApplication.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.33440 built by: FX45W81RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.33440 built by: FX45W81RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.34003 built by: FX45W81RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitdebugging="true">


When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

My application running successfully on win7 and winxp.
but it's not running in win8.

How can we develop comparability .net windows application?

Please help me.

Thanks in Advance.


Ankit Agarwal
Software Engineer

推荐答案

如果有办法欺骗权限系统,没人会需要这样的系统。这不合逻辑吗?



你能做什么?首先,最常见的选择是:仅使用合法目录,例如,根据当前用户帐户在系统中保留的目录,或所有用户。请参阅我过去的回答:

如何找到我的程序目录 [ ^ ]。



另一种方法是为某些用户提供使用某些文件系统对象的适当权限。



最后,您可以在提升的权限下执行您的应用程序: http://www.eightforums.com/tutorials/9564-run-administrator-windows-8-a.html [ ^ ]。



你能以编程方式完成吗?当然不是,由于这个答案的第一段中提到的原因。您无法绕过UAC对话框。您只能执行以下操作:创建并嵌入应用程序清单,该清单在您启动应用程序时从一开始就请求提升的权限。具有管理权限的用户将接受或拒绝提升,但不会面临权限异常:

http://msdn.microsoft.com/en-us/library/bb756929.aspx [ ^ ]。



参见:http://en.wikipedia.org/wiki/User_Account_Control [ ^ ]。



-SA
If there was a way to trick permission system around, nobody would need such system. Isn't that logical?

What you can do? First and the most usual choice would be: work only with legitimate directories, for example, those reserved in your system according to the current user account, or for "all users". Please see my past answer:
How to find my programs directory[^].

Another approach would be giving proper permissions for using certain file system objects to certain users.

And, finally, you can execute your application under the elevated permissions: http://www.eightforums.com/tutorials/9564-run-administrator-windows-8-a.html[^].

Can you do it programmatically? Of course not, by the reason mentioned in the first paragraph of this answer. You cannot bypass the UAC dialog. You can do only one thing: create and embed the application manifest which requests elevated permissions from the very beginning, when you start the application. The user having administrative will either accept or deny elevation, but won't face the permission exception:
http://msdn.microsoft.com/en-us/library/bb756929.aspx[^].

See also: http://en.wikipedia.org/wiki/User_Account_Control[^].

—SA


这篇关于如何通过c#.net windows应用程序解决Windows 8中的权限问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆