|
Can you gave me a fix in my code
|
|
|
|
|
You just need to remove the abstract declaration for the event.
namespace program.Drawing.Fields
{
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
public interface IFieldHolder
{
event FieldChangedEventHandler FieldChanged;
void AddField(Field field);
Field GetField(FieldType fieldType);
List<Field> GetFields();
bool HasField(FieldType fieldType);
void RemoveField(Field field);
void SetFieldValue(FieldType fieldType, object value);
}
}
|
|
|
|
|
Just to expand slightly on the (correct) fix already posted: You can't put 'public' or 'abstract' on interface members, because by definition they are already public and abstract, so to prevent confusion* no access modifiers are permitted.
*: or that's what the rationale is, anyway. I think it's silly, it prevents future expansion and the fact that the default scope (public abstract) in an interface is different from that (private) in a class is more confusing than making you write 'public abstract' on things in interfaces.
|
|
|
|
|
I think it makes sense that everything in an Interface is public and abstract by definition, but I don't like default modifiers on class members.
|
|
|
|
|
|
how to authenticate the user using the active directory and then finally assign certain exccess level to the user....any help..
private bool AuthenticateAD(string userName, string password, string domain, out string message)
{
message = "";
DirectoryEntry entry = new
DirectoryEntry("LDAP://" + domain, userName, password);
try
{
object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + userName + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if (null == result)
{
return false;
}
}
catch (Exception ex)
{
message = ex.Message;
return false;
//throw new Exception("Error authenticating user. " + ex.Message);
}
return true;
}
|
|
|
|
|
You can omit the DirectorySearcher. When object obj = entry.NativeObject; succeeded, everything is OK, you can already return true .
|
|
|
|
|
Hi,
Try this to List all the users from current domain.
public static void getUser()
{
DirectoryEntry directoryEntry = new DirectoryEntry("WinNT://" + Environment.UserDomainName);
string userNames = "";
string authenticationType="";
foreach (DirectoryEntry child in directoryEntry.Children)
{
if (child.SchemaClassName == "User")
{
userNames += child.Name + Environment.NewLine;
authenticationType += child.Username + Environment.NewLine;
}
}
Console.WriteLine("************************Users************************");
Console.WriteLine(userNames);
Console.WriteLine("*****************Authentication Type*****************");
}
And this for Getting a particular user details from user's active directory
public static void fnImp() {
using (var context = new PrincipalContext(ContextType.Domain, Environment.UserDomainName))
{
using (var searcher = new PrincipalSearcher(new UserPrincipal(context)))
{
foreach (var result in searcher.FindAll())
{
DirectoryEntry de = result.GetUnderlyingObject() as DirectoryEntry;
if ((string)de.Properties["givenName"].Value == Environment.UserName)
{
Console.WriteLine();
PropertyCollection pc = de.Properties;
foreach (PropertyValueCollection col in pc)
{
Console.WriteLine(col.PropertyName + " : " + col.Value);
Console.WriteLine();
}
}
}
}
}
Console.ReadLine();
}
|
|
|
|
|
I believe that you can't authenticate a password like that against the AD; would be a security-risk, wouldn't it?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I put code into my program's UnhandledException handler that will write a Minidump using PInvoke to call the native MiniDumpWriteDump function.
However when I opened the resulting minidump in VS 2010, it contained no exception information or stack information.
Is it because the exception was "being handled" by the handler that there is no exception information?
Must I allow the program to crash, and write the dump from some outside program for there to be exception information in the minidump?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Compare your version of the code to this one[^]. The article also states what happens when you reach the exception-handler, and what's on the stack at that moment.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks. That looks like a good link.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
i want insert data from ORA to SQL 2000. and i would like use any Data Component for this idea. is possible to read from ora and insert read data to my table in SQL?
whats your idea?
|
|
|
|
|
Ubun2OS wrote: is possible to read from ora and insert read data to my table in SQL?
Yes. A simple way is to have a class to read data from Oracle (so you'll be using the Oracle data commands) and another one to write data into Sql Server (so you'll be using the Sql Server commands). Simply implement a model class to hold your data - and fill this from the Oracle one and pass it into the Sql Server one to perform the update.
Or, you could get SQL Server to do this all for you simply by writing a transformation with your Oracle database as the source of the data.
|
|
|
|
|
|
Have a 5 from me. BTW - with SQL 2000, it's DTS not SSIS.
|
|
|
|
|
Pete O'Hanlon wrote: with SQL 2000, it's DTS not SSIS.
Yes, but I assume that SSIS will work with instances of SQL Server 2000 -- it's just ADO.net underneath.
|
|
|
|
|
Ok, I'm sure this is a simple question but how would I create subobjects within an object?
I want to create an object that lists the "status" of my application, to determine if it ran ok or not.
So I want to have validation code like the following:
Status status = RunReport();
if(status.Exception)
{
string exceptionMessage = status.Exception.Message;
string stackTrace = status.Exception.StackTrace;
}
Or....perhaps this:
Status status = RunReport();
if(status.Success)
{
}
So my question is, how could I setup my "Status" object to have examples like the following:
Status.Success (boolean)
Status.Exception (boolean)
Status.Exception.Message (string)
Status.Exception.StackTrace (string)
Thanks.
|
|
|
|
|
You can define your own Status type (class or struct). It could have whatever public fields (or better properties) you like.
You would instantiate such type like any other. Maybe so:
public Status RunReport() {
...
Status status=new Status(true);
return status;
}
However, seeing you are thinking "Exception", why not use real exceptions, i.e. return results when all goes well, and throw an Exception when something goes wrong, so the caller can catch that Exception?
Goalie35 wrote: Status.Exception (boolean)
Status.Exception.Message (string)
That is not possible. Either Exception is a boolean and it hasn't subfields; or it is a composite type (with fields/properties Message, StackTrace, etc.) and then it doesn't have an overall boolean value.
I would suggest you return to your C# book and read the chapters on classes, and Exceptions.
|
|
|
|
|
It is actually possible (but note, OP, this is a flight of intellectual fancy and don't do this in real code):
class MyExceptionThing {
public string Message { get; set; }
public string StackTrace { get; set; }
public static implicit operator bool(MyExceptionThing thing) { return Message != null; }
}
class Status {
public MyExceptionThing Exception { get; private set; }
}
Custom implicit cast operators can cover a multitude of sins!
I too recommend that you do what Luc says here and expose an actual Exception (i.e. System.Exception, something that you can use throw on) if you want that information available in a status object. There is precedent for this in the Task Parallel Library and BackgroundWorker. Then you can check for
if(status.Exception != null){ ... }
|
|
|
|
|
Thanks Bob. I didn't know that, however I never felt a need for it either. I don't think I'll ever use it...
|
|
|
|
|
if you had a status object with an Exception field, then you'd test for an exception as follows:
if (status.Exception != null)
{
...
}
alternatively, you could have a "computed" property Success as follows
public class Status
{
...
public Exception Exception { get; set; }
...
public bool Success { get { return Exception == null; } }
...
}
then use it as follows:
if (status.Success)
{
...
}
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|
|
|
ToBick wrote: if any .net control is available to compare pictures like it is done with the following Flash-Control:
Your example shows two pictures side by side. I do not see a "comparison".
ToBick wrote: If not - how would you realize this in C#?
I'd load two images in two panels.
Please explain a bit more what needs be compared (picture size, colors, what?), who should do the comparison (the computer, or the user? Your example implies that the user is going to compare them by looking at them) and what the result should be like.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
what i'd like to do is shown also in the following link:
http://www.spiegel.de/panorama/vorher-nachher-grafik-so-verheerend-war-der-tsunami-a-750653.html[^]
Basically, i want to put two pictures above each other and have a "slider" which i can move with the mouse to the left or the right - the part left to the slider belongs to picture No. 1 and the part right to the slider belongs to picture No. 2
Thereby, i can compare a picture which shows the same object before and after a modification.
|
|
|
|