|
Wow, that author is brilliant! So is this one!
|
|
|
|
|
Some things you can try:
- Set the intial capacity of the list as large or larger than you think you'll need it (as others have mentioned, the List class has a constructor for this purpose). This could potentially cut the time in about half.
- Use structs rather than classes so the memory will be allocated immediately rather than in small chunks over time.
- Recycle your objects (that is, don't make new objects... save them for use later).
|
|
|
|
|
Hi,
I want to generate from an PDF Images.
But how??
My favorite iTextSharp.
thx
|
|
|
|
|
|
Thanks Yusuf!
I now... but i can´t find a exampel (iTextSharp) to gernerate thumbnails
In IText NOT in ITextSharp can i use this function: decoder.getPageAsImage(PageNumber)
But how can i create thumbnails with iTextSharp???
thx!!!
|
|
|
|
|
I don't know as I never worked with iTextSharp.
We use imagemagick[^] and GhostScript[^] to generate thumbnails of PDF files. But that is completely different way of doing it.
Is there something you can make use in here[^]?
|
|
|
|
|
I am trying to write code so that if the local admins are not certain predefined accounts or groups, then they are removed.
The closest I have gotten is the code below, but it stops at the children.Remove(badObject) line and fails saying it isn't the correct format. Can anyone help please?
string userName = "WinNT://computername/test12";
userName = userName.Substring(userName.Length - 6);
DirectoryEntry de = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
DirectoryEntries children = de.Children;
DirectoryEntry badObject = children.Find("userName");
children.Remove(badObject);
de.CommitChanges();
|
|
|
|
|
Hi Guys,
Wondering if you can help me figure this out.
Here is an Example:
I have a class:
---------------
This class exist in my web service as well as my test windows appication.
public class ADUser
{
private string _name;
private string _surname;
public string Name{get {return _name;}set {_name = value;}}
public string Surname{get {return _surname;}set {_surname = value;}}
}
Here is an example of my Web Service and WebMethod:
---------------------------------------------------
List<ADUser> mylist = new List<AdUser>();
AdUser user = null;
//The method populates users from active directory into a list
private void PopulateList()
{
foreach (User in active directory)
{
user = new AdUser();
user.Name = "displayName";
user.Surname = "lastname";
mylist.Add(user);
}
}
[WebMethod]
public List<ADUser> GetUserList()
{
PopulateList();
return mylist;
}
This is my Desktop Application
------------------------------
WebService1 ws = new WebService();
List<ADUser> list = new List<ADUser>();
list = new List<ADUser>(ws.GetUserList());
This is the error I get:
The best overloaded method match for 'System.Collections.Generic.List<WindowsFormsApplication1.ADUsers>.List(System.Collections.Generic.IEnumerable<WindowsFormsApplication1.ADUsers>' has some invalid arguments
and if I user list = ws.GetUserList(); I get the error:
Cannot implicitly convert type 'WindowsFormsApplication1.myService.ADUsers[]' to 'System.Collections.Generic.List<WindowsFormsApplication1.ADUsers>
I have tried list.AddRange I have tried Arrays. All I want is the list that gets populated in my web service to be returned to my application.
Could you please help..
Thanks
|
|
|
|
|
even though you've declared that the WebMethod returns a List<aduser>, the interface is simplified to ADUser[] (array of ADUser).
So, you need to use the ToList() extension method
using System.Linq;
...
List<ADUser> list = ws.GetUserList().ToList();
"If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
|
|
|
|
|
Hi ahmed,
I tried using List<ADUsers> list = ws.GetUserList().ToList();
This is the error I get now:
Cannot Implicitly convert type System.Collections.Generic.List < WindowsFormsApplication1.myService.ADUsers > to
System.Collections.Generic.List < WindowsFormsApplication.ADUsers >
|
|
|
|
|
somehow you're using an ADUsers class from two different namespaces. C# will see these as two different types (as indeed they are) even if they are identical in definition.
Make sure the declaration of
List<ADUsers> list
is using the same namespace as the one from
ws.GetUserList()
see your using statements for a clue.
Or try
List<WindowsFormApplication1.myService.ADUsers> list = ws.GetUserList().ToList();
do you understand?
"If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
|
|
|
|
|
The clue to the problem is in the error, and it's hard to spot at a glance. Basically though, you are trying to cast WindowsFormApplication.ADUsers to WindowsFormApplication1.ADUsers (I've highlighted the difference). In other words, you have 2 versions of ADUsers; one in WindowsFormApplication and one in WindowsFormApplication1, and they aren't the same class.
|
|
|
|
|
There is some application .exe and class library .dll.
Exe uses dll functions.
Is it possible inside dll code get exe assembly that calls its functions?
Чесноков
|
|
|
|
|
|
I need exe name, full path, version, architecture.
GetCallingAssembly and GetExecutingAssembly returns .dll one, not .exe
Чесноков
|
|
|
|
|
GetEntryAssembly?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
yes, thanks, I've just found that one also
Чесноков
|
|
|
|
|
How could i make a Multi-language installer in Visual Studio Deployment and Setup project?I want the installer to show the option to select the language, then the GUI of the installer will be changed to the selected language. Thanks
|
|
|
|
|
Wrong forum. Please try the Visual Studio forum.
|
|
|
|
|
Hi,
I'm trying to copy from lets say column "AC" to column "AA". The cell contains a formula which I have gotten and built an array out of the spreadsheet. Where I am stuck is how do you get the formula to update. IE: If the formula was =ROUND(AC25) when I copy it programatically to column AA, it still says =ROUND(AC25) instead of =ROUND(AA25).
I know I can use the replace command and do a string replacement, however if the formula is: =ROUND(A5+AB5) and is in column C, when I try to replace the A to a C, it becomes =ROUND(C5+CB5) instead of =ROUND(C5+AB5).
So my question is there a built in method into the Excel that I can call to perform the cell copy updating the formulas such as Excel does when you do it by hand?
Thank you,
Glenn
|
|
|
|
|
Hello Glenn,
Not sure if it will help, but most of the Excel problems I had, I solved by recording a macro while doing it in excel,
and then just transalte/adapt VBA to C#/Excel interop. Worked like a charm. It should work in your case too.
All the best,
Dan
|
|
|
|
|
Hi to all developers.
I try to program something like Yahoo messenger ( school project).
I write tow program, Server and Client. when a client request new account, server receive the command and made new user object but it won't add new user to database. in server every socket process within a thread.
I debug line by line, everything is OK ( I think ..! )
I also try update my DB via Stored procedure, but no luck
for more details take a look at my code.
any help appreciate.
User table:
http://i52.tinypic.com/2hyvskn.jpg
private void CommandReceived(object sender, CommandEventArgs e)
{
switch (e.Command.CommandType)
{
case CommandsType.NewUser:
{
int ret = CreateNewUser(e.Command.SenderUsername, e.Command.MetaData);
Command cmd = new Command(CommandsType.NewUser, "server", e.Command.SenderUsername, ret.ToString());
SendCommandToTarget(cmd);
UpdateConsole("new client registration ", "", IPAddress.None, 0);
break;
}
}
}
private int CreateNewUser(string u, string pne)
{
try
{
RMData db = new RMData();
string username = u;
string password = pne.Split(new char[] { ':' })[0];
string email = pne.Split(new char[] { ':' })[1];
Users user = db.Users.SingleOrDefault(usr => usr.Username == username);
if (user != null)
return 1;
user = db.Users.SingleOrDefault(usr => usr.Email == email);
if (user != null)
return 2;
user = new Users();
user.Username = username;
user.AddedDate = DateTime.Now;
user.Email = email;
user.Password = password;
db.Users.InsertOnSubmit(user);
return 0;
}
catch (Exception ex)
{
return 3;
}
}
whole project:
http://www.mediafire.com/?bf5e5d6lqoolbbs
Password is: 123
N
o
N
ame
modified on Tuesday, January 25, 2011 5:16 PM
|
|
|
|
|
Use all available information, and when that does not work for you, tell it in this thread. "Does not work" is not helpful.
Always give expectations and symptoms.
You should:
- add a try-catch in CommandReceived
- in each catch, log the entire Exception using Exception.ToString()
- watch for the line numbers in the exceptions and in your source editor windows.
NoName_ark wrote: catch (Exception ex)
{
return 3;
}
Don't swallow exceptions like that, you're throwing away valuable information.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
thanks for your reply.
I debug my code, there is no error in my code that try block catch it!.
I told everything is alright. the function return return zero ( no error)
I just can't step in to db context. actually debugger can't do it.
I will upload whole project, if there is no problem take a look at it, and debug only server side program.
U can put a check point in CammandReceived line.
In client side I just complete new user. Please try create new user form.
Very thanks for your time.
http://www.mediafire.com/?bf5e5d6lqoolbbs
Password is: 123
N
o
N
ame
|
|
|
|
|
No thanks, nobody is going to download and debug your project for you, it is your job. Now start by improving your code, give it better observability, and if any problems are left, ask specific questions here with sufficient detail.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|