|
I completely agree with the logic of two application version but was just hoping as the majority of my application with work with windows 64bit that I could just decide the DLL to use at runtime. It is definitely an issue using the 32bit DLL on 64bit windows.
Thanks for you input
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
This[^]is not what you need, but might help you device a way to accomplish your task.
Another thought that came to my mind is adding references through code. You can check if the system is 32 or 64 bit and add reference accordingly. However, I am not sure how big a change you code will undergo if you follow this approach.
Best way, IMO and as stated by Vilmos, would be to have to versions - one for 32-bit and other for 64.
modified on Thursday, July 16, 2009 11:54 AM
|
|
|
|
|
d@nish wrote: and as stated by Nagy
psst: It's Vilmos, but don't tell anyone!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Oh...modified.
|
|
|
|
|
I said don't tell everyone, sheesssh!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi,
i have a Class User which inherits from other classes:
public class User : BizObject, INotifyPropertyChanged
{
In another class I want to get all members of the User Object using Reflection:
class ObjectHelper<T>
{
public static Dictionary<string, List<Object>> Compare(T oldObject, T newObject)
{
Type type = typeof(T);
Dictionary<string, List<Object>> props = new Dictionary<string, List<Object>>();
PropertyInfo[] properties = type.GetProperties(BindingFlags.DeclaredOnly);
As far as I understand the BindingFlags.DeclaredOnly flag, inherited members should not be considered.
But in my case this flag delivers absolutely no properties.
When I just use type.GetProperties() without flags, I get all members, including the (not wanted) inherited ones from the BizObject Class.
|
|
|
|
|
That's because the overload with no arguments calls the overload with a flag argument with the flags (Public | Static | Instance)
If you add those flags to your DeclaredOnly, you should get what you want.
Reflector to the rescue!!
|
|
|
|
|
Thank you, it works now
|
|
|
|
|
Hi,
I'm toying around with generics and have run into a little problem. My class is a tree, but this is not about whether or not one should make a tree this way - what I'm trying to do adds complexity for just a little lazy-coding benefit, so please ignore the particular example - I just want to understand if what I wanted to do can be done with generics.
Here's the TreeNode class:
abstract public class TreeNode<T>
{
TreeNode<T> parent;
List<TreeNode<T>> children = new List<TreeNode<T>>();
T data;
public TreeNode() { }
public T Data
{
get { return data; }
set { data = value; }
}
public TreeNode<T> Parent
{
get { return parent; }
set { parent = value; }
}
public List<TreeNode<T>> Children
{
get { return children; }
set { children = value; }
}
}
Now, let's say we want to derive a class for organizing tags into trees. The data is just a string, and for convenience we may want a constructor that sets the text of the node. I'm trying to see if there is a way to write a utility method that would take any treenode (necessarily derived since the base class is abstract) and a collection of node *data* objects and create child nodes with the data and parent set. The following snippet illustrates the Tag and how code might use the utility method to create a hard-coded hierarchy of tags:
public class Tag : TreeNode<string>
{
public Tag() {}
public Tag(string text) { Data = text; }
}
class usingTags
{
Tag getBuiltIn()
{
Tag root = new Tag("Built-in");
Tag[] top = TreeUtil.Add<Tag>(root, "License", "Product");
TreeUtil.Add<Tag>(top[0], "CPOL", "MIT", "Proprietary");
TreeUtil.Add<Tag>(top[1], "Banco", "Acco", "Piccolo");
return root;
}
}
Based on this, the utility method should be something like this:
static public TNode[] Add<TNode, T>(TNode parent, params T[] data) where TNode : TreeNode<T>, new()
{
List<TNode> list;
if (parent == null)
list = parent.Children;
else
list = new List<TNode>();
int startIndex = list.Count;
foreach (T item in data) list.Add(new TNode() { Data = item });
return list.GetRange(startIndex, list.Count - startIndex).ToArray();
}
Two problems present themselves:
1) The first assignment to "list" does not build, the compiler complaining it cannot convert List<TreeNode<T>> to List<TNode>, which I think is odd since I have defined a type constraint which guarantees that TNode either is or is derived from TreeNode<T>.
2) If I change that assignment so it assigns null instead, just to be able to build, the code *using* it does not compile. I thought the type of T could be inferred, since TNode is TreeNode<T> and the params T[] parameter is an array of strings. But the compiler just says the method requries two type parameters.
Is there a way to solve these problems so the user of the utility method need only supply the node type to create and the actual values for node data?
|
|
|
|
|
You might want to edit that, pasting your code again with "Encode HTML tags when pasting" set. Gets me every time, too (and normaly the other way - set when I want it off - as well).
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
The problem is that it then does that to the <pre> tags as well... But I guess that is at least preferrable to losing all the generics "tags". Thanks for pointing it out.
|
|
|
|
|
It's "Do not interpret HTML tags" that screws up pre tags in a post. Encode HTML tags when pasting only affects stuff in your paste buffer, and normally you don't copy/paste pre tags.
The European Way of War: Blow your own continent up.
The American Way of War: Go over and help them.
|
|
|
|
|
Well, encode when pasting usually screws up too because I will frequently cut and paste around text as I'm writing a post, leading to < becoming < (or &lt; in "source view") and so on. I personally think it a bit incredulous that this format-on-paste should be necessary; most other forums have solved this problem by using square brackets for a few basic formatting tags ([b], [i], and so on). Perhaps a code forum would need a slightly more obscure syntax since code can contain all sorts of text, but imho the current solution is not on par with the average forum out there.
In any case, I edited my post after it was brought to my attention there was a formatting issue, so if anyone has anything to say about my actual issue I would be interested to hear from them.
|
|
|
|
|
dojohansen wrote: most other forums have solved this problem by using square brackets for a few basic formatting tags
True, I suppose teh bigger question is if html input on CP is default deny or still default allow. I know in the past there were problems with idiots using bits of html to intentionally break a forum page, but I'm not sure how they were ultimately fixed.
I haven't done enough with templating to be able to answer the question itself, sorry.
The European Way of War: Blow your own continent up.
The American Way of War: Go over and help them.
|
|
|
|
|
The problem is that just because TNode derives from TreeNode<T>, they may not be the same type. This is the same reason you can't do something like:
List<Stream> list = new List<MemoryStream>();
Did you try something like this:
static public TreeNode<T>[] Add<T>(TreeNode<T> parent, params T[] data)
|
|
|
|
|
Thanks for the reply.
I see now that the normal rules of assignment are violated; List<TDerived> is not a List<TBase> even if TDerived derives from TBase. They are just two different constructed types, and since it is so there is no way to convert between them.
The problem with using static public TreeNode<T>[] Add<T>(TreeNode<T> parent, params T[] data) is that I cannot put a type constraint on the constructed type; in order to add new nodes the constructed type must have a default constructor.
This problem can be solved by keeping the method declaration but use a List<TBase> as local variable instead:
static public TNode[] Add<TNode, T>(TNode parent, params T[] data) where TNode : TreeNode<T>, new()
{
List<TreeNode<T>> list;
if (parent != null)
list = parent.Children;
else
list = new List<TreeNode<T>>();
int startIndex = list.Count;
foreach (T item in data)
list.Add(new TNode() { Data = item });
return (TNode[])list.GetRange(startIndex, list.Count - startIndex).ToArray();
}
In the end it's all futile though. Basically, I wanted to write a generic TreeNode type which can be parameterized by type of node data. But rather than the use constructed types directly, such as TreeNode<string>, I wanted to derive non-generic types from constructed types, potentially adding functionality to each type of tree node, as in class Tag : TreeNode<string> { ... } , but I didn't stop to think; Tag.Children would still be List<TreeNode<string>> rather than List<Tag>, the desired type.
|
|
|
|
|
Hallo,
I am writing an application that has the option to startup with new data (The well known 'new') button; by executing 'new' I want some or all Objects being repainted and reinitialized like they when starting the application.
For example I have an tabControlView with several tabs. I want them all completely clear. As well as a listview in a tab.
I already tried some things but with no success. I tried
tabControlViews.Invalidate(true); but nothing seemed to happen.
Do you have any hints?
Regards,
Chris
|
|
|
|
|
Hi,
calling Invalidate() on a Control tells it there now is a mismatch between its content and its rendering on the screen. MSDN says: "Invalidates a specific region of the control and causes a paint message to be sent to the control." So that is not what you need.
Some Controls have special methods to clear themselves, or their data collections (e.g. ListBox.Items.Clear). Simpler ones can be cleared through a property, as in Label.Text; the ultimate way to start afresh is by recreating the Control (and maybe the Form, which is easier when you added the Controls through Visual Studio).
The one hint I have is: go to the main MSDN page on the Control of interest, get the list of methods and properties, and read through them. Use the doc, don't abuse the gurus.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Thursday, July 16, 2009 9:38 AM
|
|
|
|
|
If "new" really should be like restarting the application, the easiest way to do it might be to actually restart the application, like this:
void btnReset_Click(object sender, EventArgs e)
{
Application.Restart();
}
This is the only easy way I can think of to guarantee that all state, including any statics you may be using, child forms and so on, is truly reset. But it may not be a good solution if your app is slow to start up.
With default startup location this will cause the app to "move" (of course the form is really a new form, but it's location will be displaced relative to the one that was destroyed when you restarted the application). You can get around this if you use another startup location, like CenterScreen, but it will look odd if the user moves or resizes the form before restarting.
An alternative way to do it if it's only UI state you want to reset might be this:
void btnReset_Click(object sender, EventArgs e)
{
int[] n = { Left, Top, Width, Height };
Controls.Clear();
InitializeComponent();
Left = n[0];
Top = n[1];
Width = n[2];
Height = n[3];
}
This obviously will only reset the form in question. But it's general at least, so you could incorporate such logic into your custom base class for forms, so only one piece of code needs to be modified should you wish to change any of it later on.
|
|
|
|
|
Hi,
This is from Chandrakanth,
Actually i have been working on asp.net with c#.
My problem is.....
I Going to update new user details into Database(SQLSERVER), and at the same time i am going to send some securitycode(AlphaNumeric),confirmation link to the particular USER MailID.
So here i am getting some problem that is i have to provide some link to user. By Clicking that link a new .aspx page should be OPEN.
How can i create LINK for the USER.
Can any one give me reply for this.
Thanks and Regards
Chandrakanth
|
|
|
|
|
A link is simply a href in an HTML block of code. Send them an HTML page with the security code appended to the link as a querystring. If the user doesn't accept HTML mail, they'll have to copy the address into the address bar manually.
As a side note - you should really have asked this in the ASP.NET forum.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi,
Just a basic question.
I want to display the progress of an operaton that has been carried out in a seperate thread(other that UI thread) on the progress bar in windows form.
For E.g : I wanted to display the staus of database operation in a label and update the progress accordingly. The database operation consists of below operations.
- Establishing connection
- Retriving data from a query
So whenever these operations finishes, i want to update the status in the label also the progress bar concurrently.
This requires a cross-thread operation. I am able to update the UI once all the operation is finished but not part by part.
Also, how can we notify the UI thread about the completion of worker thread?
What is the best way to acheve this?
Thanks in advance!!!
Praveen Raghuvanshi
Software Engineer,
India.
|
|
|
|
|
Hi,
best way would be to use BackgroundWorker instead of Thread . See here[^]
And a special hint for you: use Thread.Sleep (250ms might work) in event handler ProgressChanged to give processing time to the ui
Kind regards
|
|
|
|
|
If I understand you correctly, you need to update a Label with the status of the connection or the status of running a query? Correct?
You can try the following which I use to identify which files I am currently processing in a Thread.
First I declare a delgate for updating the Label.
public delegate void SetLabel(Control lblctrl, string filename);
Then I define the follwing to control the invoke.
private void setFilename(Control lblctrl, string filename)
{
if (this.WindowState == FormWindowState.Minimized)
return;
if (lblctrl.InvokeRequired)
lblctrl.BeginInvoke(new SetLabel(setFilename),
new object[] { lblctrl, filename });
else
lblctrl.Text = filename;
}
This allows me to call the fucntion from within any running thread. Like below:
foreach (string str2 in Directory.GetFiles(path))
{
setFilename(this.lblFileName, str2);
Hope this gives you some idea as to what I mean. You can do exactly the same for the progress bar.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Hello just a simple question, can somebody tell what is the format of writing an if statement with these characters ":" or "?". i can across this once but don't know where.
Thanks
Back off i am coding
|
|
|
|
|