Click here to Skip to main content
16,006,442 members
Home / Discussions / C#
   

C#

 
AnswerRe: draw Pin
Dalek Dave4-Mar-11 13:27
professionalDalek Dave4-Mar-11 13:27 
QuestionMOVEFILEEX fails in WIN7 Pin
Manikantagupta26-Feb-11 22:51
Manikantagupta26-Feb-11 22:51 
AnswerRe: MOVEFILEEX fails in WIN7 Pin
Luc Pattyn26-Feb-11 23:27
sitebuilderLuc Pattyn26-Feb-11 23:27 
GeneralRe: MOVEFILEEX fails in WIN7 Pin
OriginalGriff27-Feb-11 0:22
mveOriginalGriff27-Feb-11 0:22 
AnswerRe: MOVEFILEEX fails in WIN7 Pin
Luc Pattyn27-Feb-11 9:01
sitebuilderLuc Pattyn27-Feb-11 9:01 
GeneralRe: MOVEFILEEX fails in WIN7 Pin
OriginalGriff27-Feb-11 21:33
mveOriginalGriff27-Feb-11 21:33 
AnswerRe: MOVEFILEEX fails in WIN7 Pin
DaveAuld27-Feb-11 3:13
professionalDaveAuld27-Feb-11 3:13 
AnswerRe: MOVEFILEEX fails in WIN7 Pin
avinash51027-Feb-11 3:37
avinash51027-Feb-11 3:37 
Hello,

Here is the answer for ur question... The following may help u well...


To have your C# (or any .NET program) run as Administrator in Windows, you'll have to create a manifest for it. What is a manifest file? I think Microsoft explains it best:

Every assembly, whether static or dynamic, contains a collection of data that describes how the elements in the assembly relate to each other. The assembly manifest contains this assembly metadata. An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes. The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE file that contains only assembly manifest information. (link to the entire MSDN article)

With a Manifest you're able to tell Windows Vista that your C# program wants to run as Administrator. This will cause the Vista confirmation window to pop up asking the user to grant the program access. Running as Administrator in Vista is required, for example, if your program is trying to create a WCF endpoint.

The following manifest XML tells the .NET Framework to run the Assembly that you specify as Administrator within Windows Vista:



<?xml version="1.0" encoding="utf-8" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="someExecName"
type="win32" />
<description>Your Program Description</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" />
</requestedPrivileges>
</security>
</trustInfo></assembly>


add this manifest file to ur c# application as follows

Goto project-->properties-->add manifest file
and debug ur program then it works better...

Avinash...
QuestionHow to iterate in recursion? Pin
shivamkalra26-Feb-11 9:45
shivamkalra26-Feb-11 9:45 
AnswerRe: How to iterate in recursion? Pin
Luc Pattyn26-Feb-11 10:22
sitebuilderLuc Pattyn26-Feb-11 10:22 
GeneralRe: How to iterate in recursion? Pin
shivamkalra26-Feb-11 10:50
shivamkalra26-Feb-11 10:50 
AnswerRe: How to iterate in recursion? Pin
Luc Pattyn26-Feb-11 11:22
sitebuilderLuc Pattyn26-Feb-11 11:22 
GeneralRe: How to iterate in recursion? Pin
shivamkalra26-Feb-11 13:48
shivamkalra26-Feb-11 13:48 
GeneralRe: How to iterate in recursion? Pin
Luc Pattyn26-Feb-11 13:50
sitebuilderLuc Pattyn26-Feb-11 13:50 
QuestionWriting sql command from c# Pin
teknolog12326-Feb-11 9:32
teknolog12326-Feb-11 9:32 
AnswerRe: Writing sql command from c# Pin
Luc Pattyn26-Feb-11 10:25
sitebuilderLuc Pattyn26-Feb-11 10:25 
AnswerRe: Writing sql command from c# Pin
OriginalGriff26-Feb-11 20:52
mveOriginalGriff26-Feb-11 20:52 
GeneralRe: Writing sql command from c# Pin
teknolog12327-Feb-11 7:39
teknolog12327-Feb-11 7:39 
GeneralRe: Writing sql command from c# Pin
Dave Kreskowiak27-Feb-11 11:59
mveDave Kreskowiak27-Feb-11 11:59 
GeneralRe: Writing sql command from c# Pin
OriginalGriff27-Feb-11 21:31
mveOriginalGriff27-Feb-11 21:31 
GeneralRe: Writing sql command from c# Pin
teknolog12327-Feb-11 23:11
teknolog12327-Feb-11 23:11 
GeneralRe: Writing sql command from c# Pin
OriginalGriff27-Feb-11 23:22
mveOriginalGriff27-Feb-11 23:22 
GeneralRe: Writing sql command from c# Pin
teknolog12327-Feb-11 23:44
teknolog12327-Feb-11 23:44 
AnswerRe: Writing sql command from c# Pin
Bernhard Hiller28-Feb-11 0:38
Bernhard Hiller28-Feb-11 0:38 
GeneralRe: Writing sql command from c# Pin
teknolog12328-Feb-11 1:08
teknolog12328-Feb-11 1:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.