Click here to Skip to main content
15,890,557 members
Home / Discussions / C#
   

C#

 
GeneralRe: What is an Integer Pin
MicroVirus3-Sep-11 18:26
MicroVirus3-Sep-11 18:26 
GeneralRe: What is an Integer Pin
Pete O'Hanlon31-Aug-11 21:04
mvePete O'Hanlon31-Aug-11 21:04 
AnswerRe: What is an Integer Pin
V.1-Sep-11 1:22
professionalV.1-Sep-11 1:22 
GeneralRe: What is an Integer Pin
Luc Pattyn1-Sep-11 2:31
sitebuilderLuc Pattyn1-Sep-11 2:31 
AnswerRe: What is an Integer Pin
PIEBALDconsult1-Sep-11 3:10
mvePIEBALDconsult1-Sep-11 3:10 
GeneralRe: What is an Integer Pin
Shameel1-Sep-11 6:00
professionalShameel1-Sep-11 6:00 
GeneralRe: What is an Integer Pin
Roger Wright1-Sep-11 20:08
professionalRoger Wright1-Sep-11 20:08 
QuestionC#.net object reference error Pin
dcof31-Aug-11 11:32
dcof31-Aug-11 11:32 
<pre>How you tell me how to change the C#.net desktop 2008 logic so it will compile clean and the logic works? The problem is I am trying to create an instance of an object in a static class

In this application I want to create a 'class with methods for accessing the active directory' from all parts of the solution file. As part of this logic change when a user clicks on the desktop shortcut and they are not assigned to any active directory groups, I want to throw an error message stating 'do not have access-contact network administrator and throw them out of the application.

The logic to check the user credentials comes from the main method that is a 'static' method in program.cs.

The code I want to add to the main methos is as follows:

ActiveDirectoryUser CurUser;

CurUser = new ActiveDirectoryUser();

However I get the following errors:

-
Error 55 'Desktop.CurUser': cannot declare instance members in a static class

Error 56 The type or namespace name 'ActiveDirectoryUser' could not be found (are you missing a using directive or an assembly reference?)

Error 57 The type or namespace name 'ActiveDirectoryUser' could not be found (are you missing a using directive or an assembly reference?)

The cLass i want to reference looks like the following:

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Reflection;
using System.IO;
using System.Threading;
using System.Web;
using System.Windows.Forms;
using System.Security.Principal;

namespace EnrollTrac.Common
{
public class ActiveDirectoryUser
{
public ActiveDirectoryUser()
{
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

if ((!Thread.CurrentPrincipal.IsInRole("testit")))


{
MessageBox.Show("You do not have authortity.Please contact your network administrator"," Error", essageBoxButtons.OK, MessageBoxIcon.Error);
return;

}

else

{
Application.Run(new Desk());
break;
}
</pre>
AnswerRe: C#.net object reference error Pin
Eddy Vluggen31-Aug-11 11:59
professionalEddy Vluggen31-Aug-11 11:59 
QuestionTextbox onTextChanged method. Pin
vanikanc31-Aug-11 9:59
vanikanc31-Aug-11 9:59 
AnswerRe: Textbox onTextChanged method. Pin
#realJSOP31-Aug-11 10:08
mve#realJSOP31-Aug-11 10:08 
GeneralRe: Textbox onTextChanged method. Pin
vanikanc31-Aug-11 10:13
vanikanc31-Aug-11 10:13 
AnswerRe: Textbox onTextChanged method. Pin
Luc Pattyn31-Aug-11 12:51
sitebuilderLuc Pattyn31-Aug-11 12:51 
GeneralRe: Textbox onTextChanged method. Pin
BillWoodruff2-Sep-11 2:21
professionalBillWoodruff2-Sep-11 2:21 
QuestionObserver Design Patterns! Pin
borges0231-Aug-11 8:52
borges0231-Aug-11 8:52 
AnswerRe: Observer Design Patterns! Pin
Pete O'Hanlon31-Aug-11 9:22
mvePete O'Hanlon31-Aug-11 9:22 
QuestionWhat's the difference between Proxy Patterns and Observer Patterns? Pin
borges0231-Aug-11 7:44
borges0231-Aug-11 7:44 
AnswerRe: What's the difference between Proxy Patterns and Observer Patterns? Pin
Abhinav S31-Aug-11 8:00
Abhinav S31-Aug-11 8:00 
QuestionC#.net class library error Pin
dcof31-Aug-11 7:22
dcof31-Aug-11 7:22 
AnswerRe: C#.net class library error PinPopular
Wayne Gaylard31-Aug-11 7:34
professionalWayne Gaylard31-Aug-11 7:34 
QuestionCustom Control Regions Pin
cjb11030-Aug-11 23:58
cjb11030-Aug-11 23:58 
AnswerRe: Custom Control Regions Pin
BobJanova31-Aug-11 0:27
BobJanova31-Aug-11 0:27 
GeneralRe: Custom Control Regions Pin
cjb11031-Aug-11 0:40
cjb11031-Aug-11 0:40 
GeneralRe: Custom Control Regions Pin
BobJanova31-Aug-11 7:43
BobJanova31-Aug-11 7:43 
GeneralRe: Custom Control Regions Pin
cjb1102-Sep-11 2:27
cjb1102-Sep-11 2:27 

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.